|
I have no problem with people asking for help - what you're trying to do is not easy. I helped someone with a very similar problem last week, so please look back a few days for my name in a chain conversation.
It just amused me that you were posting on codeproject asking about threads on a different website!
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
Hi Experts,
I am filling a file content with Zero and renamed it and Delete it.
but when I rename the file and try to delete it, file file's lost contents are come back.
If I do not Rename the file everything is fine.
Its like
1.Fill content with Zero
2. szString=RenameFile(szString)
3. DeleteFile(szString);
But I put a Sleep(2000) in between 2 and 3 It works well but get slow.
Is there any workaround?
Thank You.
|
|
|
|
|
pther wrote: Fill content with Zero
You have to close the file handle first!
pther wrote: 2. szString=RenameFile(szString)
3. DeleteFile(szString);
CopyFile("Src.txt", "Dest.txt", FALSE);
DeleteFile("Src.txt");
Or
rename("Src.txt", "Dest.txt");
Maxwell Chen
|
|
|
|
|
Same I used in RenNameFile();
rename(szSourceFilePath,szNewFilePath);
|
|
|
|
|
pther wrote: Same I used in RenNameFile();
rename(szSourceFilePath,szNewFilePath);
The file might be locked.
Maxwell Chen
|
|
|
|
|
CopyFile() create another copy of that file. I do not want to create any other copy of this file.
Actuelly we want to delete the actual file not Copied file.
|
|
|
|
|
pther wrote: CopyFile() create another copy of that file. I do not want to create any other copy of this file.
It was one of the approaches to do the renaming task. Or you may try:
MoveFile("oldname", "newname");
Maxwell Chen
|
|
|
|
|
Hello,
Can you please help me understand CreateProcess() function.
I am new to this concept.
Syntax of CreateProcess() is: -
BOOL CreateProcess(
PCTSTR pszApplicationName,
PTSTR pszCommandLine,
PSECURITY_ATTRIBUTES psaProcess,
PSECURITY_ATTRIBUTES psaThread,
BOOL bInheritHandles,
DWORD fdwCreate,
PVOID pvEnvironment,
PCTSTR pszCurDir,
PSTARTUPINFO psiStartInfo,
PPROCESS_INFORMATION ppiProcInfo);
My Code snippet is: -
STARTUPINFO si = { sizeof(si) };
PROCESS_INFORMATION pi;
TCHAR szPath[] = TEXT("C:\\Documents and Settings\\abhishekc\\Desktop\\code.txt");
bool bIsProcessCreated = CreateProcess(TEXT("c:\\windows\\SYSTEM32\\notepad.exe"),szPath,NULL, NULL,FALSE, 0,
NULL, NULL, &si, &pi);
Output: -
A new Notepad file opens and dialog pop-up "The System cannot find the specified path".
====================================================================================
All the path provided are true.
CreateProcess() returns true.
I am confused among two parameters of CreateProcess() viz: PCTSTR pszApplicationName,
PTSTR pszCommandLine.
Thanks in advance.
|
|
|
|
|
Do it this way:
BOOL b = CreateProcess(
NULL,
_T("notepad.exe C:\\Documents and Settings\\abhishekc\\Desktop\\code.txt"),
NULL,
...
);
Maxwell Chen
|
|
|
|
|
|
and as a side note: whenever there is white space in the parameters to CreateProcess, make it as single parameter by adding quote to the string.
otherwise there is chance to interpret as multiple parameters
TCHAR szPath[] = TEXT("C:\\Documents and Settings\\abhishekc\\Desktop\\code.txt");
can be changed to the following, to be in safer side.
TCHAR szPath[] = TEXT("\"C:\\Documents and Settings\\abhishekc\\Desktop\\code.txt\"");
ps: i am sure this is not the problem.
|
|
|
|
|
can i embed vlc player to my application. its a dialog based application. there is activex control available for it.
|
|
|
|
|
Hi,
Can anyone please tell me a way/hint to embed word document into a C++ console based exe.
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
|
|
|
|
|
u mean u want to embed in console window strange
|
|
|
|
|
Innovative!
Maxwell Chen
|
|
|
|
|
Everyone knows that when you press the 'Enter' key or 'ESC' key in a dialog application, even if in a CEdit ctrl that has focus, the dialog will exit. If you want to prevent this unwantable annoying default behavior, you should write some code.
There is an atricle about how to catch those Enter keys in controls at CP. The author tell us to add a hanled to catch WM_GETDLGCODE message,if the function's return code is DLGC_WANTALLKEYS , then our controls will know every message and we have the right to decide what to do to those 'Enter','ESC' keys.
So I subclass a CEdit class called CMyEdit, and added two message handlers OnGetDlgCode and OnKeyDown. In CMyEdit's OnKeyDown function, I can catch VK_RETURN and VK_ESCAPE , and the dialog will not exit even if Enter or ESC is pressed in the edit ctrl. Hooray!
But!!! when I change this CMyEdit from singleline to multiline, everything changed! Now OnKeyDown function will not see VK_ESCAPE any more, but VK_RETURN is still catched. And when the ESC is pressed in the ctrl, dialog exit. Why DLGC_WANTALLKEYS doesn't work now?
After I googled for half a day. I found a solution--override CEdit's PreTranslateMessage and catch all key's there.
I want to known why DLGC_WANTALLKEYS works well for single line CEdit but not for multiline?
And which is the best way to prevent dialog from exiting when the ESC or Enter is pressed in a CEdit ctrl?
Thank you all!
A Chinese VC++ programmer
|
|
|
|
|
The simplest solution, working well, and you won't need to override anything of CEdit class:
void CTestDlg::OnBtnClickedCancel()
{
CWnd* pWnd = GetFocus();
if(pWnd == dynamic_cast<CWnd*>(&m_ctlEditMultiline)) {
return;
}
OnCancel();
}
Maxwell Chen
|
|
|
|
|
Yes, If you handle the ESC key in the upmost dialogbox, the there will be many if there. If the focus is in a edit box then blablala, and If the focus is in a listctrl then something else.
This is why I appreciate handling the WM_GETDLGCODE message. Then each control has its own way to handle key message. I believe the code will be cleaner. But it doesn't works well for multiline CEdit ctrls.
Any way, Thank you Maxwell Chen
A Chinese VC++ programmer
|
|
|
|
|
Maxwell Chen
|
|
|
|
|
I want to write a small program to play-back the video media on a Blu-ray disc.
But i found it is difficult.
Someone tells me the files have been encrypted. I know some other videos would be encrypted,dvd and so on,but only copying is forbidden(playing is allowed).
Then,how should I play the videos on a Blu-ray disc? If the video should be decrypted,how should i implement it?
Regards.
|
|
|
|
|
I am writing a code in C++ to read out a Registry key Value. The program runs with no errors but instead of reading the value either shows nothing (in case value == 0) or shows funny face symbols (if value == 1 or other values). Once this value is read I would also need to assign it to a variable. Any solution would be highly appreaciated!
///// code /////
HKEY MyKey;
unsigned long type=REG_SZ, size=1024;
char res[1024]="";
RegOpenKeyEx
(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\0", 0, KEY_READ, &MyKey);
RegQueryValueEx
(MyKey, "1400\0", NULL, &type, (LPBYTE)&res[0], &size);
cout << "Ant the value is.....: " << *(LPBYTE)&res[0] << endl;
RegCloseKey (MyKey);
///////////////////
|
|
|
|
|
Why are you unnecessarily adding \0 to the string literals.
J_E_D_I wrote: RegQueryValueEx
(MyKey, "1400\0", NULL, &type, (LPBYTE)&res[0], &size);
Why are you not reading this into a DWORD type?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How the heck did you determine it should be a DWORD from that code???
I'm way more curious about the LPBYTE cast when displaying the "string"...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ahh now I see it (the DWORD) in the registry
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
(I swear yesterday I saw my message succesfully posted on the website, but today I can't find it anymore! So I'm posting it again).
David, I followed your advice and tried to read it into a DWORD type, but still it doesn't seem to work. What am I doing wrong? Besides reading the registry value, I need to assign it to a variable. Help please!
HKEY MyKey;
DWORD dwLen = sizeof(DWORD);
DWORD dwKeyEn = 0;
RegOpenKeyEx
(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3", 0, KEY_READ, &MyKey);
RegQueryValueEx(hKey, "1400", NULL, NULL,(LPBYTE)&KeyEn, &dwLen);
cout << "And the value is.....: " << *(LPBYTE)&KeyEn << endl;
RegCloseKey (MyKey);
|
|
|
|
|