Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CreateProcessWithLogonW returns error
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00875077
Message ID:
00875081
Views:
22
I did:

How to Start a Process as Another User (NT/XP/2K)
http://www.news2news.com/vfp/?example=426&function=696

Here is your solution -- convert strings to Unicode, cheer up :)
LOCAL cProcInfo, cStartInfo, nResult, hProcess, hThread
cProcInfo = REPLICATE(CHR(0), PROC_INFO_SIZE)
cStartInfo = PADR(CHR(START_INFO_SIZE), START_INFO_SIZE, CHR(0))
cDomain = ConvStr(cDomain)
cUsr = ConvStr(cUsr)
cPwd = ConvStr(cPwd)
cApp = ConvStr(cApp)
cCmd = ConvStr(" " + ALLTRIM(cCmd))  && note a leading space
cDir = ConvStr(cDir)

	nResult = CreateProcessWithLogonW(cUsr, cDomain, cPwd,;
		LOGON_WITH_PROFILE, cApp, cCmd, CREATE_DEFAULT_ERROR_MODE,;
		0, cDir, @cStartInfo, @cProcInfo)
...
FUNCTION ConvStr(cStr)
#DEFINE STRCONV_UNICODE  5
RETURN STRCONV(cStr+CHR(0), STRCONV_UNICODE)
Previous
Reply
Map
View

Click here to load this message in the networking platform