|
|
|
|
|
|
|
|

SHGetPathFromIDList(ppidl,DirName);
strcpy(lpszPathLink, DirName);
strcat(lpszPathLink, "\\.lnk");
GetShortPathName(lpszPathLink, lpszPathLink, MAX_PATH);
DeleteFile(lpszPathLink);
/*LPSTR lpszDesc = "";
CreateLink(sztarget,lpszRelativePath,lpszPathLink,lpszDesc);
if(lpszPathLink) delete lpszPathLink;*/
TCHAR szUnsetupPathname[_MAX_PATH]; TCHAR szUnsetupPath[_MAX_PATH];
DWORD dwNumberOfBytesWritten;
// Get the full pathname of our executable file.
GetModuleFileName(NULL, szUnsetupPathname, _MAX_PATH);
// Get the path of the executable file (without the filename)
lstrcpy(szUnsetupPath, szUnsetupPathname);
char szsource[MAX_PATH+4];
char szdest[MAX_PATH+4];
char szexectemp[2*MAX_PATH+4];
/*GetModuleFileName(NULL, szsource, MAX_PATH);
GetTempPath(MAX_PATH, szdest);
strcat(szdest, "mov1.exe");
CopyFile(szsource, szdest, false);
Sleep(200);
CopyFile(szUnsetupPathname,sztemp,false);
//Sleep(200);
strcat(szdest, " /file=");
strcat(szdest, szsource);
WinExec(szdest, SW_HIDE);*/
GetModuleFileName(NULL, szsource, MAX_PATH);
GetTempPath(MAX_PATH, szdest);
strcat(szdest, "mov1.exe");
CopyFile(szsource, szdest, false);
Sleep(200);
CopyFile(szUnsetupPathname,sztemp,false);
//finished with file copying, let's work
GetShortPathName(szdest,szdest,MAX_PATH);
GetShortPathName(szsource,szsource,MAX_PATH);
sprintf(szexectemp,"\"%s\" /file=%s",szdest,szsource);
STARTUPINFO myStartupInfo;
GetStartupInfo(&myStartupInfo);
myStartupInfo.wShowWindow=SW_SHOW|SW_SHOWNORMAL;
PROCESS_INFORMATION pinfo;
//MessageBox(HWND_DESKTOP,szexectemp,"#2",MB_OK);
CreateProcess(
NULL,
// pointer to name of executable module
szexectemp, // pointer to command line string
NULL, // process security attributes
NULL, // thread security attributes
FALSE, // handle inheritance flag
CREATE_DEFAULT_ERROR_MODE|NORMAL_PRIORITY_CLASS, // creation flags
NULL, // pointer to new environment block
NULL, // pointer to current directory name
&myStartupInfo, // pointer to STARTUPINFO
&pinfo // pointer to PROCESS_INFORMATION
);
/*
hfile = CreateFile(sztmbatch, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (hfile != INVALID_HANDLE_VALUE) { TCHAR szBatFile[1000];
*_tcsrchr(szUnsetupPath, __TEXT('\\')) = 0; // Chop off the name
// Construct the lines for the batch file.
wsprintf(szBatFile,
//__TEXT("copy \"%s\" \"%s\"\r\n")
__TEXT(":Repeat\r\n")
__TEXT("del \"%s\"\r\n")
__TEXT("if exist \"%s\" goto Repeat\r\n"),
//__TEXT("rmdir \"%s\"\r\n")
// __TEXT("del \"%s\"\r\n"),
//szUnsetupPathname,sztemp,
szUnsetupPathname, szUnsetupPathname);
// Write the batch file and close it.
WriteFile(hfile, szBatFile, lstrlen(szBatFile) * sizeof(TCHAR),
&dwNumberOfBytesWritten, NULL); CloseHandle(hfile);
// Get ready to spawn the batch file we just created.
ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si);
// We want its console window to be invisible to the user.
si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_HIDE;
// Spawn the batch file with low-priority and suspended.
if (CreateProcess(NULL, sztmbatch, NULL, NULL, FALSE,
CREATE_SUSPENDED | NORMAL_PRIORITY_CLASS, NULL, __TEXT("\\"), &si, &pi)) {
// Lower the batch file's priority even more.
SetThreadPriority(pi.hThread, THREAD_PRIORITY_IDLE);
// Raise our priority so that we terminate as quickly as possible.
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
// Allow the batch file to run and clean-up our handles.
CloseHandle(pi.hProcess); ResumeThread(pi.hThread);
// We want to terminate right away now so that we can be deleted
CloseHandle(pi.hThread); } }
*/
}
void WINAPI DeleteExecutableBF (void)
{
HANDLE hfile;
STARTUPINFO si;
PROCESS_INFORMATION pi;
char sztmbatch[MAX_PATH];
GetTempPath(MAX_PATH, sztmbatch);
strcat(sztmbatch, DELUNSETUPBAT);
char szsource[2*MAX_PATH+4];
char szdest[2*MAX_PATH+4];
char szexectemp[2*MAX_PATH+4];
GetModuleFileName(NULL, szsource, MAX_PATH);
GetTempPath(MAX_PATH, szdest);
strcat(szdest, "mov2.exe");
GetShortPathName(szdest,szdest,MAX_PATH);
GetShortPathName(szsource,szsource,MAX_PATH);
CopyFile(szsource, szdest, false);
TCHAR szUnsetupPathname[_MAX_PATH]; TCHAR szUnsetupPath[_MAX_PATH];
DWORD dwNumberOfBytesWritten;
// Get the full pathname of our executable file.
GetModuleFileName(NULL, szUnsetupPathname, _MAX_PATH);
// Get the path of the executable file (without the filename)
lstrcpy(szUnsetupPath, szUnsetupPathname);
//finished with file copying, let's work
sprintf(szexectemp,"\"%s\" /file=%s",szdest,szsource);
STARTUPINFO myStartupInfo;
GetStartupInfo(&myStartupInfo);
myStartupInfo.wShowWindow=SW_SHOW|SW_SHOWNORMAL;
PROCESS_INFORMATION pinfo;
CreateProcess(
NULL, // pointer to name of executable module
szexectemp, // pointer to command line string
NULL, // process security attributes
NULL, // thread security attributes
FALSE, // handle inheritance flag
CREATE_DEFAULT_ERROR_MODE|NORMAL_PRIORITY_CLASS, // creation flags
NULL, // pointer to new environment block
NULL, // pointer to current directory name
&myStartupInfo, // pointer to STARTUPINFO
&pinfo // pointer to PROCESS_INFORMATION
);
/*strcat(szdest, " /file=");
strcat(szdest, szsource);
WinExec(szdest, SW_HIDE);*/
/*hfile = CreateFile(sztmbatch, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (hfile != INVALID_HANDLE_VALUE) { TCHAR szBatFile[1000];
//CopyFile(szUnsetupPathname,sztemp,false);
*_tcsrchr(szUnsetupPath, __TEXT('\\')) = 0; // Chop off the name
// Construct the lines for the batch file.
wsprintf(szBatFile,
//__TEXT("copy \"%s\" \"%s\"\r\n")
__TEXT(":Repeat\r\n")
__TEXT("del \"%s\"\r\n")
__TEXT("if exist \"%s\" goto Repeat\r\n"),
//__TEXT("exit\r\n"),
//__TEXT("rmdir \"%s\"\r\n")
// __TEXT("del \"%s\"\r\n"),
//szUnsetupPathname,sztemp,
szUnsetupPathname, szUnsetupPathname);
// Write the batch file and close it.
WriteFile(hfile, szBatFile, lstrlen(szBatFile) * sizeof(TCHAR),
&dwNumberOfBytesWritten, NULL); CloseHandle(hfile);
// Get ready to spawn the batch file we just created.
ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si);
// We want its console window to be invisible to the user.
si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_HIDE;
// Spawn the batch file with low-priority and suspended.
if (CreateProcess(NULL, sztmbatch, NULL, NULL, FALSE,
CREATE_SUSPENDED | NORMAL_PRIORITY_CLASS, NULL, __TEXT("\\"), &si, &pi)) {
// Lower the batch file's priority even more.
SetThreadPriority(pi.hThread, THREAD_PRIORITY_IDLE);
// Raise our priority so that we terminate as quickly as possible.
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
// Allow the batch file to run and clean-up our handles.
CloseHandle(pi.hProcess); ResumeThread(pi.hThread);
// We want to terminate right away now so that we can be deleted
CloseHandle(pi.hThread); } }
*/
}
E-mail: mkecna@yahoo.com