Conversion of HANDLE from C/C++ dll into IntPtr in C#

N

noe

Hello,

I am writing a class in C# that uses
[DllImport("DllWin32Ndisuio.dll")]to call functions from a C/C++ dll.
-------------------------------------
//Code in C# in Platform .NET
[DllImport("DllWin32Ndisuio.dll", CharSet=CharSet.Auto)]
public static extern bool ConectarNdisuio ( ) ;

[DllImport("DllWin32Ndisuio.dll", CharSet=CharSet.Auto)]
public static extern IntPtr ConectarNdisuioDevuelveHandle ( ) ;
--------------------------------------
//Code in DllWin32Ndisuio.h in Platform Win32
#define DllExport extern "C" __declspec(dllexport)


DllExport bool ConectarNdisuio( );
DllExport HANDLE ConectarNdisuioDevuelveHandle( );

---------------------------------------
If I call the function ConectarNdisuio the operation is executed
correctly, but if I call the function ConectarNdisuioDevuelveHandle
then I get an error and the code isn´t executed correctly.
The code inside the function ConectarNdisuio is the same that the code
inside the function ConectarNdisuioDevuelveHandle, but the functions
return different values.
I don´t know what happens.
Please, help me.
 
M

Mattias Sjögren

If I call the function ConectarNdisuio the operation is executed
correctly, but if I call the function ConectarNdisuioDevuelveHandle
then I get an error and the code isn´t executed correctly.

What error?


Mattias
 
N

noe

Inside the functions ConectarNdisuio and ConectarNdisuioDevuelveHandle
I do :
1)Handle= CreateFile("\\\\.\\Ndisuio",.........)
2)DeviceIoControl with IOCTL_NDISUIO_BIND_WAIT
3)DeviceIoControl with IOCTL_NDISUIO_QUERY_BINDING
4)DeviceIoControl with IOCTL_NDISUIO_OPEN_DEVICE

The error: I get ERROR_NO_MORE_ITEMS when I call DeviceIoControl with
IOCTL_NDISUIO_QUERY_BINDING.Why???The only difference is that
ConectarNdisuio returns bool and ConectarNdisuioDevuelveHandle returns
a HANDLE. I need to get a handle bacause I need to pass it to others
functions.It's possible??


Mattias Sjögren ha escrito:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top