CreateProcessWithLogonW函数只能在console程序中调用吗?
下面的代码可以运行。但是在一个其他的工程中(比如基于Dialog的)调用CreateProcessWithLogonW时,提示说没有定义,弄了半天,没有解决。请指教:)
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <stdio.h>
int wmain(int argc, WCHAR *argv[])
{
if (argc != 4) {
wprintf(L"Usage: %s user pwd cmd\n", argv[0]);
return -1;
}
STARTUPINFOW si;
ZeroMemory(&si,sizeof(si));
si.cb= sizeof(si);
PROCESS_INFORMATION piProcess;
if (!CreateProcessWithLogonW(argv[1], L"", argv[2], 0, argv[3], NULL, 0,
NULL, NULL, &si, &piProcess)) {
wprintf(L"err [%u]\n", GetLastError());
}
return 0;
}