Click here to Skip to main content
15,908,111 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
please help me
i have a function say :----

EXPORT_IMPORT int __cdecl getDevices ( char ** pDeviceList, int * pDeviceCount ,unsigned long ulFlags ) this is in c++
i m working in c# and want to import dll and need to call function in my main from my unmanged dll.
please note that i have to pass parametrs while calling function in main accrding to the parameterts which i have mention in my function prototype above
so just send me the whole code to call this function.
i have code to import my dll just ahve a look on it--

[DllImport(@"C:\WINDOWS\WinSxS\unmanged.dll", SetLastError = true)]
public static unsafe extern int getDevices(char ** pDeviceList, int * pDeviceCount, uint ulFlags);

i m sucessfully able to import my dll but not able to call function i m getting error

Error 1 The best overloaded method match for 'ConsoleApplication2.getDevices() has some invalid arguments


Error 2 Argument '1': cannot convert from 'char**' to 'ref System.Text.StringBuilder'

Error 3 Argument '2': cannot convert from 'int*' to 'System.IntPtr'

when i pass these parametrts
let say getDevice(ref StringBuilder pDeviceList, IntPtr pDeviceCount, ulong ulFlags);

tell me what parametrs i have to pass from my function equivalent to this arguments while calling function in main from my unmanaged dll.
please note that i need to know what parametrs i have to pass from my function in order to call my function.
because i have several function with parametrs of different data types.
so please let me know sir abt it as soon as possible.

Aasif Eqbal Aslam
aasifaslamy85@gmail.com
Posted
Updated 25-Jan-10 0:49am
v2

1 solution

aasif aslam wrote:
[DllImport(@"C:\WINDOWS\WinSxS\unmanged.dll", SetLastError = true)]
public static unsafe extern int getDevices(char ** pDeviceList, int * pDeviceCount, uint ulFlags);


The first thing you should do is stop using unsafe. There's no reason to do that. The second thing you should do is try to find a Windows API function that accepts a char** and/or int* parameter, and then go to pInvoke.net to see how THEY send parameters to that/those API function(s).



 
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