I am attempting to call WNetAddConnection2 from OI. The Visual Basic declaration is as follows:
Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" (lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal lpUserName As String, ByVal dwFlags As Long) As Long
The problem is that I don't see any way to get OI to send a string as a parameter "Byval", only as a reference.
First, is it true that byval parameter passing is not possible in the OI implementation? Is there a workaround?
Second, here's my workaround idea: If my byval strings are both less than eight characters, maybe I can define the parameters as "double" and pass them that way. Can anyone think of any reason why this would not work?
Wayne Shepard
Zadek, Inc.
Wayne,
Use LPSTR for both lpPassword and lpUserName. If you look at the documentation WNetAddConnection2 here at msdn.microsoft.com, these parameters are declared as pointers to constant strings.
Pat
Thanks. I guess "byval" means something different from what I thought it meant. Anyway, I did that and now I'm getting an error "ENG0805: MYPROG line 70, Function WNetAddConnection2 does not exist in dynamic link library MPR." I can't find anything in that Windows Networking documentation that says what the correct name of the DLL is. I was trusting my Visual Basic example for that. Do you know where I can find that out?
Wayne
Wayne,
Hidden at the bottom of this page at MSDN it states the function is in the MPR library.
Sean
Wayne,
Sean is correct, it IS in MPR.DLL but you need to specify the ANSI or Unicode version of the function:
ie WNetAddConnection2A or WNetAddConnection2W
and alias it as WNetAddConnection2 when you prototype it.
World leaders in all things RevSoft
Thanks. I was wondering what that was for. I've gotten past that error and now I'm having a problem with GetPointer that I've raised under a new topic.