問題描述
誰能告訴我如何在 VC++ 中創建一個進程?我需要執行
Can anyone tell me how to create a process in VC++? I need to execute
regasm.exe testdll /tlb:test.tlb /codebase
該過程中的命令.
推薦答案
regasm.exe
(程序集注冊工具)對 Windows 注冊表進行更改,因此如果您想啟動 regasm.exe
作為提升的進程,您可以使用以下代碼:
regasm.exe
(Assembly Registration Tool) makes changes to the Windows Registry, so if you want to start regasm.exe
as elevated process you could use the following code:
#include "stdafx.h"
#include "windows.h"
#include "shellapi.h"
int _tmain(int argc, _TCHAR* argv[])
{
SHELLEXECUTEINFO shExecInfo;
shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
shExecInfo.fMask = NULL;
shExecInfo.hwnd = NULL;
shExecInfo.lpVerb = L"runas";
shExecInfo.lpFile = L"regasm.exe";
shExecInfo.lpParameters = L"testdll /tlb:test.tlb /codebase";
shExecInfo.lpDirectory = NULL;
shExecInfo.nShow = SW_NORMAL;
shExecInfo.hInstApp = NULL;
ShellExecuteEx(&shExecInfo);
return 0;
}
shExecInfo.lpVerb = L"runas"
表示該進程將以提升的權限啟動.如果您不想要,只需將 shExecInfo.lpVerb
設置為 NULL.但在 Vista 或 Windows 7 下,更改 Windows 注冊表的某些部分需要管理員權限.
shExecInfo.lpVerb = L"runas"
means that process will be started with elevated privileges. If you don't want that just set shExecInfo.lpVerb
to NULL. But under Vista or Windows 7 it's required administrator rights to change some parts of Windows Registry.
這篇關于如何在 Windows 上用 C++ 創建進程?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!