Re: CreateProcessA Lib "kernel32" problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: vbVeryBeginner (anonymous_at_anonymous.com)
Date: 07/08/04


Date: Thu, 8 Jul 2004 10:01:01 +0800

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



Relevant Pages

  • Re: CreateProcessA Lib "kernel32" problem
    ... The VB viewer defines some variables as the data type expected, eg As String ... do is to search for that function using the VB provided API Viewer. ... ByVal lpProcessAttributes As Long, _ ... ByVal lpApplicationName As String (VB API Declaration) ...
    (microsoft.public.vb.winapi)
  • Re: SHELL Command problem
    ... Shell is a braindead function loosely based on the ShellExecute ... API declaration that I copied in from the API Viewer. ... "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal ...
    (comp.lang.basic.visual.misc)
  • Re: How to Call API as is VC?
    ... You should use PInvoke. ... declaration and use it like any other function. ... Keep in mind that this API Viewer has a flaw, ... replace string for StringBuilder... ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Calling CreateSemaphore from VB
    ... >declaration, and here is how my declaration currently stands: ... >The only difference between what I have and what API Viewer has, ... Public Declare Function CreateSemaphore Lib "kernel32" _ ... You need to shutdown the IDE or explicitly release/close ...
    (microsoft.public.vb.general.discussion)
  • Re: Form_MouseDown
    ... > My API viewer does not list them. ... open it and click on the Find in Files toolbar button ... declaration is just a safe-guard. ... constant definition that is a WORD and is 0xFFFF. ...
    (microsoft.public.vb.general.discussion)