Denney Posted September 20, 2004 Share Posted September 20, 2004 I have a problem. The function I want to call is as follows:VOID CALLBACK InstallHinfSection( HWND hwnd, HINSTANCE ModuleHandle, PCTSTR CmdLineBuffer, INT nCmdShow);My problem is I cannot figure out how to pass my string to CmdLineBuffer.I've tried passing it as a string and I cannot figure the whole pointers in Visual Basic thing out.Can anyone help me with this?Edit: Here is how I'm currently declaring this function (I think CmdLineBuffer is wrong):' Note ModuleHandle should be Nothing and nCmdShow should be 0.Declare Auto Sub InstallHinfSection Lib "setupapi" Alias "InstallHinfSection" (ByVal hwnd As String, ByVal ModuleHandle As String, ByVal CmdLineBuffer As String, ByVal nCmdShow As Integer) Link to comment Share on other sites More sharing options...
HeartsOfWar Posted September 20, 2004 Share Posted September 20, 2004 The documentation of the function you're wanting to call is written specifically for a C / C++ environment.However, you can achieve what you need done by making a call to the console using this syntaxRUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection <section> <mode> <path>Replace <section> with the type of installationReplace <mode> with 128 or 132replace <path> with the absolute path to the *.inf fileThis will kick-off the installation using the *.inf file as the driver...for more information see here - http://msdn.microsoft.com/library/default....hinfsection.aspORyou could just call the setupapi.dll and use the internal library, pass the values, and go from there. Link to comment Share on other sites More sharing options...
CoffeeFiend Posted September 21, 2004 Share Posted September 21, 2004 (edited) . Edited November 7, 2006 by crahak Link to comment Share on other sites More sharing options...
Denney Posted September 21, 2004 Author Share Posted September 21, 2004 @HeartsOfWar: 1. I was using that before but I want to get rid of the need to call external applications like that.2. That is what I'm doing but I don't seem to sending the write values.@crahak: Thanks.Basically, what I need to is, what is the Visual Basic equivilent (sp?) of C's "PCTSTR"? How can I pass the equivilent (sp?) of a "PCTSTR" in Visual Basic .NET?At the moment, the function call works but then setupapi gives a message box saying "Installation failed". The input string is CORRECT and using the exact same input string but making an external call to rundll32 works.If only it was a LPTSTR, it would work... How the hell do I convert a PCTSTR?Thanks for your help though. Link to comment Share on other sites More sharing options...
HeartsOfWar Posted September 21, 2004 Share Posted September 21, 2004 From all the documentation I can find, you are doing everything right...Here is what I've found....VOID CALLBACK InstallHinfSection( HWND hwnd, HINSTANCE ModuleHandle, PCTSTR CmdLineBuffer, INT nCmdShow);Declare function InstallHinfSection Lib "setupapi" Alias "InstallHinfSection" (ByVal hwnd As String, ByVal ModuleHandle As String, ByVal CmdLineBuffer As String, ByVal nCmdShow As Integer) as longThe only thing I see different from yours is you declared yours as an Auto Sub, and you didn't include a 'As long' at the end.I'm not sure if this helps or makes a difference, but I have also discovered that Visual Basic can use a BSTR in the place of a LPCSTR, so ByVal CmdLineBuffer As String is correct... definately.. no conversion needed Link to comment Share on other sites More sharing options...
Denney Posted September 21, 2004 Author Share Posted September 21, 2004 Well, InstallHinfSection doesn't return a value so "Sub" is correct... With or without Auto it still won't work.I've tried for about 3 days on this so I'm going back to calling "rundll32.exe". Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now