(重复帖子,忽略)如何从非托管dll调用函数

问题描述:


任何人都可以帮我吗?
我正在尝试调用一个函数say getdevice();
出现在我的非托管dll中. dll中的函数具有参数
getdevice(char ** pDeviceList,int * pDeviceCount,unsigned longulFlags)
实际上我正在使用c#并在c#中进行编码,并且我的dll在c ++中,而我的应用程序的整个编码也在c ++中,但是我想导入我的dll并调用我的函数,我有导入我的dll的代码,但不知道如何调用函数以及我必须从main()传递的参数
我不知道用c#编码时调用dll中存在的函数时传递参数的正确数据类型和正确方法.

在c#中是否有可能从main()调用dll中存在的函数时将指针作为参数传递? 因为从上面可以看出,function( getdevice())带有poeners作为参数.
在c#中,是否有任何方法可以通过函数传递指针以从main()调用函数
Aasif Eqbal
aasifaslamy85@gmail.com

hi ,
Please can anyone help me ?
i m trying to call a function say getdevice();
which is present in my unmanaged dll. the function in dll has parameters say
getdevice(char **pDeviceList,int *pDeviceCount, unsigned longulFlags)
actually i m using c# and doing coding in c# as well and my dll is in c++ and whole coding of my application is also in c++ but i want to import my dll and call my functions , I have code to import my dll but dont know how to call the function and what parametrs i have to pass from main()
I dont know while coding in c# the proper datatypes and proper way for the parameters to pass while calling my function present in dll .

Is it possible in c# to pass pointers as parametrs while calling a function present in dll from main()
because as it can be seen above function(getdevice()) has poniters as parameters.
In c# Is there any way to pass pointers through a function to call a function from main()
Aasif Eqbal
aasifaslamy85@gmail.com

您可以使用PInvoke调用非托管方法.有关详细信息,请查看以下文章.

http://msdn.microsoft.com/en-us/library/aa446536.aspx [ ^ ]
http://msdn.microsoft.com/en-us/magazine/cc164123.aspx [ ^ ]
You can call your unmanaged methods using PInvoke. Check the folllowing articles for details.

http://msdn.microsoft.com/en-us/library/aa446536.aspx[^]
http://msdn.microsoft.com/en-us/magazine/cc164123.aspx[^]