Hi All,
I have a code written in C++ which i need to consume in C# Application.
Below are the syntax's of the two methods which i need to use in my C# application:
long __declspec (dllimport) MyMethod1(const wchar_t* inputFileName, const wchar_t* outputFileName)
__declspec (dllimport) int __stdcall MyMethod2(void ** pMyVoidPtr, MY_CUSTOM_STRUCT* pMyCustomStruct);
I could use them in my C++ Application as below:
MyMethod1(_T("C:\\InputFile.txt"), _T("C:\\OutputFile.txt"));
MY_CUSTOM_STRUCT myCustomStruct;
void* pVoidPtr = NULL;
MyMethod2(&pVoidPtr, &myCustomStruct);
In C++ Application, i could get the desired results. But in C# Application, the Pointer pVoidPtr always returns NULL.
I have tried using ref, out IntPtr as parameters but everything failed.
Could anyone provide me the syntax for the same in C# Application (For both the methods)?
Thanks and Regards,
Kishor Reddy
What I have tried:
[DllImport("Exported Dll Path")]
long static extern MyMethod1(string strInputName, string strOutputName);
[DllImport("Exported Dll Path")]
int static extern MyMethod2(out IntPtr pVoidPtr, MY_CUSTOM_STRUCT myCustomStruct);
[DllImport("Exported Dll Path")]
int static extern MyMethod2(out IntPtr pVoidPtr, IntPtr myCustomStruct);