请问这个怎么运行?
#include<windows.h>
#include<stdlib.h>
#include<tchar.h>
#include "stdafx.h"
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,int nCmdShow)
{
if(__argc == 1){
TCHAR szPathOrig[_MAX_PATH], szPathClone[_MAX_PATH];
GetModuleFileName(NULL, szPathOrig, _MAX_PATH);
GetTempPath(_MAX_PATH, szPathClone);
GetTempFileName(szPathClone, __TEXT("Del"), 0, szPathClone);
CopyFile(szPathOrig, szPathClone, FALSE);
HANDLE hfile = CreateFile(szPathClone, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, NULL);
TCHAR szCmdLine[512];
HANDLE hProcessOrig = OpenProcess(SYNCHRONIZE, TRUE, GetCurrentProcessId());
wsprintf(szCmdLine, __TEXT("%s %d \"%s\""), szPathClone, hProcessOrig, szPathOrig);
STARTUPINFO si;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
PROCESS_INFORMATION pi;
CreateProcess(NULL, szCmdLine, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
CloseHandle(hProcessOrig);
CloseHandle(hfile);
}
else{
HANDLE hProcessOrig = (HANDLE) _ttoi(__targv[1]);
WaitForSingleObject(hProcessOrig, INFINITE);
CloseHandle(hProcessOrig);
DeleteFile(__targv[2]);
}
return 0;
}
错误
错误 1 error C2146: syntax error : missing ';' before identifier 'WinMain' c:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\2\2\2.cpp 6
错误 2 error C2065: 'HINSTANCE' : undeclared identifier c:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\2\2\2.cpp 6
错误 3 error C2146: syntax error : missing ')' before identifier 'hInstance' c:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\2\2\2.cpp 6
错误 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\2\2\2.cpp 6
错误 5 error C2059: syntax error : ')' c:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\2\2\2.cpp 8
错误 6 error C2143: syntax error : missing ';' before '{' c:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\2\2\2.cpp 9
#include<stdlib.h>
#include<tchar.h>
#include "stdafx.h"
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCmdLine,int nCmdShow)
{
if(__argc == 1){
TCHAR szPathOrig[_MAX_PATH], szPathClone[_MAX_PATH];
GetModuleFileName(NULL, szPathOrig, _MAX_PATH);
GetTempPath(_MAX_PATH, szPathClone);
GetTempFileName(szPathClone, __TEXT("Del"), 0, szPathClone);
CopyFile(szPathOrig, szPathClone, FALSE);
HANDLE hfile = CreateFile(szPathClone, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_DELETE_ON_CLOSE, NULL);
TCHAR szCmdLine[512];
HANDLE hProcessOrig = OpenProcess(SYNCHRONIZE, TRUE, GetCurrentProcessId());
wsprintf(szCmdLine, __TEXT("%s %d \"%s\""), szPathClone, hProcessOrig, szPathOrig);
STARTUPINFO si;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
PROCESS_INFORMATION pi;
CreateProcess(NULL, szCmdLine, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
CloseHandle(hProcessOrig);
CloseHandle(hfile);
}
else{
HANDLE hProcessOrig = (HANDLE) _ttoi(__targv[1]);
WaitForSingleObject(hProcessOrig, INFINITE);
CloseHandle(hProcessOrig);
DeleteFile(__targv[2]);
}
return 0;
}
错误
错误 1 error C2146: syntax error : missing ';' before identifier 'WinMain' c:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\2\2\2.cpp 6
错误 2 error C2065: 'HINSTANCE' : undeclared identifier c:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\2\2\2.cpp 6
错误 3 error C2146: syntax error : missing ')' before identifier 'hInstance' c:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\2\2\2.cpp 6
错误 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\2\2\2.cpp 6
错误 5 error C2059: syntax error : ')' c:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\2\2\2.cpp 8
错误 6 error C2143: syntax error : missing ';' before '{' c:\Documents and Settings\user\My Documents\Visual Studio 2005\Projects\2\2\2.cpp 9
...全文
相关推荐
无法从 int? 转换为 int 运行时出现错误
当我们试图将`int?`转换为`int`时,需要确保`int?`变量不是`null`。这是因为直接转换会尝试将`null`值赋给非可空类型,这会导致编译错误或运行时异常。
怎样提高电脑运行速度?.docx
这些临时文件占用了电脑的资源,影响了电脑的运行速度。我们可以采取什么措施来删除这些临时文件呢?
如何提高CAD的运行效率?.docx
如何提高CAD的运行效率?docx,CAD教程,CAD,中望,科技,设计
js脚本,随机选择去哪里吃饭?静态html,直接运行
js脚本,随机选择去哪里吃饭?静态html,直接运行
Wincc RT advanced如何生成运行文件以及如何在电脑上运行?.docx
**在其他电脑上运行**: 如果要在其他电脑上运行Wincc RT Advanced项目,你需要将Generates文件夹整个复制到目标计算机。


VC.NET
