Re: CreateProcessA Lib "kernel32" problem
From: Randy Birch (rgb_removethis_at_mvps.org)
Date: 07/08/04
- Next message: Peter Young: "Re: Renamed VB6 NT Service still has previous name in Services console?!"
- Previous message: Randy Birch: "Re: Download from network places"
- In reply to: vbVeryBeginner: "Re: CreateProcessA Lib "kernel32" problem"
- Next in thread: Tom Esh: "Re: CreateProcessA Lib "kernel32" problem"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 8 Jul 2004 10:34:35 -0400
The VB viewer defines some variables as the data type expected, eg As String
or As SECURITY_ATTRIBUTES (a user-defined type). Others will declare those
members As Long and will pass a memory pointer to where the string or
SECURITY_ATTRIBUTES UDT exists. For strings one uses StrPtr(sTheString). For
SECURITY_ATTRIBUTES Byval 0& is often used to indicate no
SECURITY_ATTRIBUTES are being set, meaning use the current thread's security
settings. If you want to get technical, under the hood VB passes everything
as a Long value anyway representing the memory address of the particular
variable's contents. Therefore some declares are simply defined to accept
Long values anyway.
-- Randy Birch MVP Visual Basic http://vbnet.mvps.org/ Please respond only to the newsgroups so all can benefit. "vbVeryBeginner" <anonymous@anonymous.com> wrote in message news:40ecaa0c_2@news.tm.net.my... : thanks first, zoury and gale green : : now, this is funny. : i figure out how to did it but i don't really understand what going on. : let say i am going to use the WIN32 API CreateProcess, the first step i will : do is to search for that function using the VB provided API Viewer. : : it ask me to declare using the following statement : : 01> Private Declare Function CreateProcess Lib "kernel32" Alias : "CreateProcessA" ( _ : 02> ByVal lpApplicationName As String, _ : 03> ByVal lpCommandLine As String, _ : 04> lpProcessAttributes As SECURITY_ATTRIBUTES, _ : 05> lpThreadAttributes As SECURITY_ATTRIBUTES, _ : 06> ByVal bInheritHandles As Long, _ : 07> ByVal dwCreationFlags As Long, _ : 08> lpEnvironment As Any, _ : 09> ByVal lpCurrentDriectory As String, _ : 10> lpStartupInfo As STARTUPINFO, _ : 11> lpProcessInformation As PROCESS_INFORMATION) As Long : : and after much desperate tries to figure out what went wrong, i try : downloading some other example code and to my astonishment, they use a : DIFFERENT declaration! : : 01> Private Declare Function CreateProcessA Lib "kernel32" ( _ : 02> ByVal lpApplicationName As Long, _ : 03> ByVal lpCommandLine As String, _ : 04> ByVal lpProcessAttributes As Long, _ : 05> ByVal lpThreadAttributes As Long, _ : 06> ByVal bInheritHandles As Long, _ : 07> ByVal dwCreationFlags As Long, _ : 08> ByVal lpEnvironment As Long, _ : 09> ByVal lpCurrentDirectory As Long, _ : 10> lpStartupInfo As STARTUPINFO, _ : 11> lpProcessInformation As PROCESS_INFORMATION) As Long : : the differences are : #2 : ByVal lpApplicationName As String (VB API Declaration) : ByVal lpApplicationName As Long (Their Declaration) : : #4 : lpProcessAttributes As SECURITY_ATTRIBUTES (VB) : ByVal lpProcessAttributes As Long (Their) : : #5 : lpThreadAttributes As SECURITY_ATTRIBUTES (VB) : ByVal lpThreadAttributes As Long (Their) : : #8 : lpEnvironment As Any (VB) : ByVal lpEnvironment As Long (Their) : : #9 : ByVal lpCurrentDriectory As String (VB) : ByVal lpCurrentDirectory As Long (Their) : : i have NO LUCK using the VB provided API Viewer but able to start the : notepad.exe using THEIR declaration. now, why the VB declaration can't run! : because i thought the VB API Viewer should be the official resource of API : declaration. Should i trust the VB API Viewer anymore? : : i also have an PSDK august 2001 edition. : : BOOL CreateProcess( : LPCTSTR lpApplicationName, // name of executable module : LPTSTR lpCommandLine, // command line string : LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD : LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD : BOOL bInheritHandles, // handle inheritance option : DWORD dwCreationFlags, // creation flags : LPVOID lpEnvironment, // new environment block : LPCTSTR lpCurrentDirectory, // current directory name : LPSTARTUPINFO lpStartupInfo, // startup information : LPPROCESS_INFORMATION lpProcessInformation // process information : ); : : according to this API, the declaration provided by the VB API Viewer SHOULD : be correct, but WHY it can't runs ??? : : as a vbVeryBeginner, i hope this won't discourage me...:) : sincerely hope somebody here in NG would love to explain to me...WHY... : thanks : : : : : :
- Next message: Peter Young: "Re: Renamed VB6 NT Service still has previous name in Services console?!"
- Previous message: Randy Birch: "Re: Download from network places"
- In reply to: vbVeryBeginner: "Re: CreateProcessA Lib "kernel32" problem"
- Next in thread: Tom Esh: "Re: CreateProcessA Lib "kernel32" problem"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|