Click here to Skip to main content
15,897,371 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: A thread that creates multiple dialogs Pin
bu7ch3r18-Mar-10 9:52
bu7ch3r18-Mar-10 9:52 
GeneralRe: A thread that creates multiple dialogs Pin
Eugen Podsypalnikov18-Mar-10 9:57
Eugen Podsypalnikov18-Mar-10 9:57 
GeneralRe: A thread that creates multiple dialogs Pin
bu7ch3r18-Mar-10 9:59
bu7ch3r18-Mar-10 9:59 
QuestionHow Could I Use a define macro identifier in an other define macro replacement list? Pin
A&Ms18-Mar-10 4:08
A&Ms18-Mar-10 4:08 
AnswerRe: How Could I Use a define macro identifier in an other define macro replacement list? Pin
«_Superman_»18-Mar-10 4:21
professional«_Superman_»18-Mar-10 4:21 
GeneralRe: How Could I Use a define macro identifier in an other define macro replacement list? Pin
A&Ms18-Mar-10 4:39
A&Ms18-Mar-10 4:39 
AnswerRe: How Could I Use a define macro identifier in an other define macro replacement list? [modified] Pin
KarstenK18-Mar-10 5:03
mveKarstenK18-Mar-10 5:03 
General[typo] Re: How Could I Use a define macro identifier in an other define macro replacement list? Pin
Nuri Ismail18-Mar-10 5:52
Nuri Ismail18-Mar-10 5:52 
GeneralRe: [typo] Re: How Could I Use a define macro identifier in an other define macro replacement list? Pin
KingsGambit18-Mar-10 8:28
KingsGambit18-Mar-10 8:28 
QuestionCommunication between PCs over a wireless network Pin
Member 184003918-Mar-10 2:53
Member 184003918-Mar-10 2:53 
AnswerRe: Communication between PCs over a wireless network Pin
Moak18-Mar-10 2:59
Moak18-Mar-10 2:59 
QuestionHow to check if a HWND is static icon ctrl? Pin
sashoalm18-Mar-10 2:46
sashoalm18-Mar-10 2:46 
AnswerRe: How to check if a HWND is static icon ctrl? PinPopular
Chris Losinger18-Mar-10 3:05
professionalChris Losinger18-Mar-10 3:05 
Questionunicode to multibyte Pin
Member 59031018-Mar-10 2:21
Member 59031018-Mar-10 2:21 
AnswerRe: unicode to multibyte PinPopular
Adam Roderick J18-Mar-10 2:37
Adam Roderick J18-Mar-10 2:37 
AnswerRe: unicode to multibyte Pin
Richard MacCutchan18-Mar-10 2:45
mveRichard MacCutchan18-Mar-10 2:45 
AnswerRe: unicode to multibyte Pin
David Knechtges18-Mar-10 3:25
David Knechtges18-Mar-10 3:25 
AnswerRe: unicode to multibyte Pin
Rajesh R Subramanian18-Mar-10 8:14
professionalRajesh R Subramanian18-Mar-10 8:14 
AnswerRe: unicode to multibyte Pin
EverettJF18-Mar-10 14:57
EverettJF18-Mar-10 14:57 
QuestionSave Image in Harddisk. Pin
ashwath197918-Mar-10 1:13
ashwath197918-Mar-10 1:13 
AnswerRe: Save Image in Harddisk. Pin
Eugen Podsypalnikov18-Mar-10 1:35
Eugen Podsypalnikov18-Mar-10 1:35 
GeneralRe: Save Image in Harddisk. Pin
ashwath197918-Mar-10 1:44
ashwath197918-Mar-10 1:44 
GeneralRe: Save Image in Harddisk. Pin
Eugen Podsypalnikov18-Mar-10 1:45
Eugen Podsypalnikov18-Mar-10 1:45 
AnswerRe: Save Image in Harddisk. Pin
KingsGambit18-Mar-10 1:48
KingsGambit18-Mar-10 1:48 
Questiondeleting folder Pin
learningvisualc18-Mar-10 0:55
learningvisualc18-Mar-10 0:55 
Hi all,

I was trying to make self deleting executable. I found a article on code project []

my problem is i am stucked at one place my folder is not getting deleted.

// temporary .bat file  
	CString templ =
	"del \"%s\"\r\n"
	"taskkill /im selfdelete.exe\r\n"
	"del \"%s\"\r\n"
    "rmdir /S /Q \"%s\"\r\n"	
    "del \"%s\"" ;

	//CString temppath;

	CString tempstr;
	CString modulename;

	LPTSTR pPath = tempstr.GetBufferSetLength(MAX_PATH);
	GetTempPath ( MAX_PATH, pPath );
	tempstr.ReleaseBuffer();
	tempstr = tempstr + tempbatname;

	LPTSTR modulenm = modulename.GetBufferSetLength(MAX_PATH);
	GetModuleFileName(NULL,modulenm,MAX_PATH) ;
	modulename.ReleaseBuffer();

	CString str = modulename;
	int k = str.Find('\\');
	while(k >= 0)
	{
		str = str.Right(str.GetLength()-k-1);
		k = str.Find('\\');
	}

	CString folder = modulename.Left(modulename.GetLength()-str.GetLength());

	CString iniFile = folder;
	CString file = "\\selfdeletepath.txt";
	iniFile = iniFile + file;

	HANDLE hf ;
	hf = CreateFile(tempstr, GENERIC_WRITE, 0, NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL) ;
	
	if (hf != INVALID_HANDLE_VALUE)
	{
		DWORD len ;
		CString bat ;
		LPTSTR bBat = bat.GetBufferSetLength(MAX_PATH);
		bat = (char*)alloca(strlen(templ) + strlen(modulename) * 2 + strlen(tempstr) + 20) ;
		wsprintf(bBat, templ,iniFile, modulename, folder, tempstr) ;
		WriteFile(hf, bat, strlen(bat), &len, NULL) ;   
		CloseHandle(hf) ;
		ShellExecute(NULL, "open", tempstr, NULL, NULL, SW_HIDE);  
	}

}


can anybody please tell me what i am doing wrong.

thanks in advance

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.