Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VB6,Win32 Api, and XP

Status
Not open for further replies.

vernlee

Technical User
Nov 14, 2003
2
US
Win32 api function calls always return with a result of 0. Any idea of what could be causing this?

Example:
lpResult = CreateProcess(strProgram, vbNullString, sa, sa, False, NORMAL_PRIORITY_CLASS, ByVal 0&, _
"", sinfo, pinfo)
LaunchResult = GetLastError

The result of this call is as follows:

lpResult = 0
LaunchResult = 0

Any idea of what's going on here?
 
Since you don't show us how you are declaring the function or what's in any of the variables passed into it we can only take a wild guess! Try:

Declare Function CreateProcessA Lib "kernel32" (Byval _
lpApplicationName As Long, Byval lpCommandLine As String, Byval _
lpProcessAttributes As Long, Byval lpThreadAttributes As Long, _
Byval bInheritHandles As Long, Byval dwCreationFlags As Long, _
Byval lpEnvironment As Long, Byval lpCurrentDirectory As Long, _
lpStartupInfo As STARTUPINFO, lpProcessInformation As _
PROCESS_INFORMATION) As Long

lpResult = CreateProcess(0&, strProgram, 0&, 0&, 0&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, sinfo, pinfo)

Sorry if that doesn't work but it was only a guess!

Paul Bent
Northwind IT Systems
 
I thought API returned 0 if successful and <> 0 if not, unless this is one of those API calls that doesn't follow thre rule.

Andy
&quot;Logic is invincible because in order to combat logic it is necessary to use logic.&quot; -- Pierre Boutroux
&quot;A computer program does what you tell it to do, not what you want it to do.&quot; -- Greer's Third Law
 

This is from the definition of createprocess in the help files...
[tt]
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

To get extended error information, call GetLastError.

Good Luck

 
Paul,

I had used a set of set of supplied pre defined declarations and assumed they were correct. Wrong!

The code segment you sent worked.

Much thanks to you.


Vern
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top