Private Type WRAPI_NDIS_DEVICE
pDeviceName As String
pDeviceDescription As String
End Type
Private Declare Function WRAPIEnumerateDevices Lib "wrapi.dll" (ppDeviceList As WRAPI_NDIS_DEVICE, plItems As Long) As Long
When I call the function, I get an error saying: "File not found: wrapi.dll", and the IDE breaks on the Declare Function statement.
The dll and the lib are both in the same folder as the project, and I also tried moving them to the System32 folder, but to no avail.
Does anyone know what I'm doing wrong? i'm not even sure if it's possible to use these functions from VB, but I would expect a slightly different error message than file-not-found. Any help is more than welcome
Tried that, same result.
It would be rather strange if it did, since that way I would have to make sure the dll had to be in that exact location if installed on another machine.
A few times I've seen odd characters get mixed in with code, like when copying/pasting from someplace. The characters in this case have no visual representation, so you don't see them, but vb just can't make heads or tails out of it, and acts in all manner of strange ways. I've found that pasting the code into the immediate window, then back into the code window seems to fix this type of thing, or you can edit the source file in notepad, but it can be tricky to find the culprit. I'd also check the filename for unintended characters, such as spaces or whatever. Other than that, I agree that vb should not be saying "file not found". Have you tried using Dir() to see if it can be located that way?
Please remember to rate the posts and threads that you find useful.
How can something be both new and improved at the same time?
As for the special characters when copy/pasting, since I only had the c++ header file to go on, I had to type the declaration myself, so that rules out any invalid characters.
Doing some further research, I pulled the dll into a utility DLL Export viewer, which shows all exported functions in a dll. The results showed up quite odd, so I suspect the dll from beeing corrupt. See attached screenshot (left is user32.dll, right is wrapi.dll).
Unfortunately, I don't have the needed skills to recompile from source, and I haven't been able to find another version of the dll.
I've just mailed the author of wrapi to see if he can come up with a solution, and check the dll for correctness, but since it doesn't appear to be a really active project, I can only hope to get a response.
IMHO, you will be not able to use this DLL in VB because the all entries have the cdecl calling convention not supported by VB.
I could load this DLL and get "Can't find DLL entry point WRAPIEnumerateDevices in D:\Forums\CodeGuru\WRAPI\wrapi.dll" expected.
***EDITED***
After adding the correct alias to this function, I have "Bad DLL calling convention" expected.
Code:
Private Declare Function WRAPIEnumerateDevices Lib "D:\Forums\CodeGuru\WRAPI\wrapi.dll" _
Alias "?WRAPIEnumerateDevices@@YAJPAPAUWRAPI_NDIS_DEVICE@@PAJ@Z" _
(ppDeviceList As WRAPI_NDIS_DEVICE, plItems As Long) As Long
Last edited by Vi2; August 12th, 2005 at 07:26 AM.
With best wishes, Vita
-----------------------
Russian Software Development Network -- http://www.rsdn.ru
Ok, that clears up a lot.
I found an example on PSC to call cdecl dll's from VB, but it keeps complaining about a wrong parameter type i'm passing (the WRAPI_NDIS_DEVICE).
I'll play with it some more to see if can get any further with that.
Do you know if it's hard to convert the dll to use _stdcall instead of cdecl? (maybe I should ask this in the VC++ forum instead). Would it require a complete rewrite, or only some subtile changes?
Q: Do you know if it's hard to convert the dll to use _stdcall instead of cdecl? (maybe I should ask this in the VC++ forum instead). Would it require a complete rewrite, or only some subtile changes?
1. You can rebuild ALL functions in project to be __stdcall convention.
2. You can rename the HRESULT into STDAPI or STDMETHODIMP in each WRAPIXXXX declarations, for example:
WRAPI HRESULT WRAPIEnumerateDevices(WRAPI_NDIS_DEVICE **ppDeviceList, long *plItems);
to
WRAPI STDAPI WRAPIEnumerateDevices(WRAPI_NDIS_DEVICE **ppDeviceList, long *plItems);
or
WRAPI STDMETHODIMP WRAPIEnumerateDevices(WRAPI_NDIS_DEVICE **ppDeviceList, long *plItems);
With best wishes, Vita
-----------------------
Russian Software Development Network -- http://www.rsdn.ru
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.