06-20-2005 09:46 AM
06-21-2005 04:29 AM
06-23-2005 12:08 PM
06-24-2005 08:08 AM
06-24-2005 11:07 AM
04-14-2011 03:46 PM
Hi,
I am trying to run a command with CreateProcessWithLogonW, but I have an error while I link my project (undefined symbol _CreateProcessWithLogonW)
Can you help to resolve my problem or send me an example ?
#include <windows.h>
#include <stdio.h>
#include <userenv.h>
#include <ansi_c.h>
#include <userint.h>
#include <toolbox.h>
#include "fenetres.h"
#include "spectrumclib.h"
#include "commun.h"
int Test(void)
{
STARTUPINFOW lpStartupInfo;
PROCESS_INFORMATION lpProcessInfo;
CreateProcessWithLogonW(
(LPCWSTR)"admin",
(LPCWSTR)"",
(LPCWSTR)"password",
(DWORD)LOGON_WITH_PROFILE,
(LPCWSTR)"cmd.exe /C",
NULL,
(DWORD)CREATE_WITH_USERPROFILE,
NULL,
NULL,
&lpStartupInfo,
&lpProcessInfo
); return 0;
}
I thanks you
Sébastien
04-15-2011 08:31 AM
Sébastien:
Do you have the Win32 API (Windows SDK) for CVI installed?
Did you add Advapi32.lib to your project? (Using the menu in the CVI project window, goto Edit >> Add files to project >> Library (*.Lib), and browse to Advapi32.lib). In older CVI versions, it was under c:\Program Files\National Instruments\MeasurementStudio\CVI\sdk\lib. In LabWindows 2010, it's under c:\Program Files\National Instruments\CVI2010\sdk\lib\msvc.
04-16-2011 01:38 AM
Hi,
Yes I have Windows SDK for CVI installed.
The Advapi32.lib is in my project.
I send you my CVI 9 project.
I think I have a problem with include.
I thanks you
04-16-2011 09:04 AM - edited 04-16-2011 09:05 AM
Sebastien:
Your includes look OK. CreateProcessWithLogonW() is defined in winbase.h, which is included in windows.h.
However, CreateProcessWithLogonW() is not defined for all versions of Windows. If you search for CreateProcessWithLogonW in winbase.h, you'll see that it is preceeded with the statement
#if(_WIN32_WINNT >= 0x0500)
So you need to #define _WIN32_WINNT
The definitions are here:
http://msdn.microsoft.com/en-us/library/aa383745.aspx
XP is 0x0501
Vista is 0x600
Windows 7 is 0x601 (Interesting. Not 0x0700?)
So if you're running Vista, insert the following statement BEFORE #include <windows.h>
#define _WIN32_WINNT 0x600
#include <windows.h>
04-16-2011 09:16 AM
P.S.
You should also check the return value for CreateProcessWithLogonW. It's a boolean: 0 means it failed, non-zero means it succeeded. For example
if (!CreateProcessWithLogonW(...))
// report error
Take a look at the MSDN help for CreateProcessWithLogonW