Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a first method of a C++ dll
1.HRESULT WINAPI StartInit(Void)
2.HREULT WINAPI LoadInitBitmap(LPWSTR IpBMPFilename, UINT uid);
How can I load the dll and define those methods.

What I have tried:

[DllImport("tjp.dll", EntryPoint = "LoadLibrary")]
       static extern IntPtr StartInit();
       public Form1()
       {
           InitializeComponent();

       }

       private void btnLoadDll_Click(object sender, EventArgs e)
       {
           var res = StartInit();

       }
Posted
Updated 9-Mar-21 22:10pm

1 solution

The DllImport declaration must define the actual entry point that you wish to call
C#
[DllImport("tjp.dll", EntryPoint = "StartInit")] // 
static extern IntPtr StartInit();

public Form1()
{
    InitializeComponent();

}

private void btnLoadDll_Click(object sender, EventArgs e)
{
    var res = StartInit();

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900