1. RE: CreateProcessWithLogonW
- Posted by Markus Schaller <markus.schaller at web.de> Mar 01, 2004
- 599 views
> -- I have added the CreateProcessWithLogonW and constants to the > -- w32engin.ew version 6.40 which can be downloaded here: > http://www.rapideuphoria.com/w32engin.zip Thanks for adding this to your w32engin.> -- If you are running windows 2000 or XP. Yes, I'm using Windows 2000; CreateProcessWithLogonW is accessible And thank you for the example. Unfortunately the function call fails and GetLastError() still returns ERROR_INVALID_PARAMETER. Do you have any idea? Markus
2. RE: CreateProcessWithLogonW
- Posted by Markus Schaller <markus.schaller at web.de> Mar 01, 2004
- 628 views
Hi Some time ago I wrote that this code doesn't work (GetLastError() returns 87). Now I found the problem. Against the documentation at http://msdn.microsoft.com/ CurrentDirectory must not be "". Just giving it a valid value, like lpCurrentDirectory = szW("C:\\WINNT") fixes the program. Now it works fine Greetings Markus Schaller > -- > ---- begin code ---- > include w32engin.ew > ---------------------------------------------------------------------------- > > --- > function Logon(sequence Username, sequence Domain, > sequence Password, sequence ApplicationName) > -- > atom lpUsername,lpDomain,lpPassword,dwLogonFlags, > lpApplicationName,lpCommandLine,dwCreationFlags,lpEnvironment, > lpCurrentDirectory,lpStartupInfo,lpProcessInformation, r > -- > lpUsername = szW(Username) -- szW creates a Unicode temporary string > lpDomain = szW(Domain) > lpPassword = szW(Password) > dwLogonFlags = LOGON_WITH_PROFILE > lpApplicationName = szW(ApplicationName) > lpCommandLine = szW("") > dwCreationFlags = CREATE_NEW_PROCESS_GROUP > lpEnvironment = NULL > lpCurrentDirectory = szW("") > lpStartupInfo = struc("STARTUPINFO") > lpProcessInformation = struc("PROCESS_INFORMATION") > -- call create process > r = CreateProcessWithLogonW({lpUsername,lpDomain,lpPassword, > dwLogonFlags,lpApplicationName,lpCommandLine, > dwCreationFlags,lpEnvironment,lpCurrentDirectory, > lpStartupInfo,lpProcessInformation}) > -- free the resources > szfree() -- frees the unicode strings > free_mem({lpStartupInfo,lpProcessInformation}) -- frees the structures > return r > end function > -- > ? Logon("admin",".","admin123","C:\\WINNT\\NOTEPAD.EXE") > ? GetLastError() > ---- end code ----