|
-
August 13th, 2005, 08:01 AM
#1
Problem calling C++ API
I'm trying to call a C++ API function, which takes two parameters. The function will fill these 2 parameters. The first parameter will be a list of a specific structure, the second will be a number indicating how many elements the array contains.
The problem is that I don't know how te define and pass the 'list' to the function. I've tried a few things, but they all fail to work. The funtion call itself succeeds, since the count parameters is set properly
This is the exported function definition in C++
Code:
HRESULT WRAPIEnumerateDevices(
WRAPI_NDIS_DEVICE** ppDeviceList
long* plItems
);
In VB.Net, I've declared the function as follows: (note that the funny name in entrypoint is indeed correct)
Code:
<DllImport("wrapi.dll", EntryPoint:="?WRAPIEnumerateDevices@@YAJPAPAUWRAPI_NDIS_DEVICE@@PAJ@Z", SetLastError:=True, CharSet:=CharSet.Unicode, ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)> _
Public Function WRAPIEnumerateDevices(ByRef ppDeviceList As WRAPI_NDIS_DEVICE, ByRef plItems As Int32) As Long
End Function
My guess is that I do not need to pass a WRAPI_NDIS_DEVICE structure, but somethign different. I just don't know what it should be. I've tried passing a WRAPI_NDIS_DEVICE element, the first element of an array of WRAPI_NDIS_DEVICE elements, but none of them worked.
If I look at a C++ example, it simply defines a WRAPI_NDIS_DEVICE element, and passes it to the function.
Code:
WRAPI_NDIS_DEVICE *pDeviceList = NULL;
hRes = WRAPIEnumerateDevices(&pDeviceList, &lItems);
for ( int i = 0; i < lItems; i++)
{
printf("%ws\n - %ws\n", pDeviceList[i].pDeviceDescription, pDeviceList[i].pDeviceName);
}
Anyone know what I should be passing here?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|