|
An alternative is use GetDc(GetDsktopWindow())->DrawText("skjjkajsa",x,y,whatever the params....)
|
|
|
|
|
hi,
i has just done like this
void CTestDlg::OnOK()
{
// TODO: Add extra validation here
CWnd *wnd = this->GetDesktopWindow();
CRect rect;
rect.top=300;
rect.left=300;
rect.bottom=rect.top+200;
rect.right=rect.left+200;
CDC *pDC = wnd->GetDC();
pDC->SetTextColor(RGB(255,255,255));
pDC->DrawText("test",rect,DT_CENTER);
// CDialog::OnOK();
}
but nothing happend.
|
|
|
|
|
I recently take care of an application. It is used for testing some hardware with the communication port.The original maintainer developed it with Win98 and VC++6.0.Then , I become the new maintainer with Win2K and VC++.NET. Basically , the application is well performed , but only one button has some trouble. Whenever I click it , there is a message window pop out.And it says "there is an unhandled exception 0xC0000005 of xxx.exe at 0x77f8910e happened . Reading address of 0x80000039 is error".Meanwhile , the frame stack stop at "NTDLL.DLL!77f8910e()".....Who , the kind people , could help me.
|
|
|
|
|
Where can I find an equivalent of HTMLEncode in Visual C++?
Something that would replace " by " etc... in a CString?
If there is nothing standard, I would be grateful if somebody would share his/her code.
Thanks in advance!
|
|
|
|
|
decode quoted is available in the following site. download the entire source code. the function decodequoted is in the source.
http://sourceforge.net/projects/yahoopops/
Have A Nice Day!
Murali.M
|
|
|
|
|
|
My program has 4 threads .
And when it runs a few minutes ,error happens.
It prompted "buffer overrun detected! A buffer overrun has been detected which has corrupted the programs's interal state.The program cannot saftly continue execution and must now be terminated."
I use vc.net to compile it.The program base on SDI,CHtmlview.
when I use vc.6.0 compile ,the error isn't happen.
I don't know the difference about vc6.0 and vc.net.
Who can tell me what operation maybe cause this error happen?
Thanks !
|
|
|
|
|
The error may well happen on vc6.0, but the runtime is not geared up to detect it (which explains many of the security exploits that MS issue patches for).
You probably have a stack based variable (typically an array) that you're overwriting beyond the boundaries (char[] are favourites for this, many of the string functions don't/can't length-check)
Steve S
|
|
|
|
|
Buffer overrun problems happen when data is written past a variables' alloted space. For example:
char str[10];
strcpy(str, "This is a very, very long line"); The compiler will not detect this, although some third-party debuggers will.
A number of recent exploits to Windows has been because of bugs like this.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
|
Hello everybody out there,
I have a dialog window application which sets current user environment variables with RegSetValueEx. The values are parsed when the user pressed the OK Button.
After the parsing a new program is launched with CreateProcess.
Everything works fine as the variables are set and the new launched program starts, but as soon as I want to check if it can read the env variables by clicking a funktion of the program, which would mainly read out the variables and create a path out of them, I have an critical error message from windows.
I guess that I have a pointer or process still adressing something that new program needs, but as I am new to this I don't have clue where to look.
Here is more or less the code I am using:
void CSetEnvDialogDlg::OnOK()
{
CString evJOBValue, evSHOTValue;// contain the values from the dialog the user has set
int index;
DWORD res;
DWORD dwRet;
// Open registry key where current user environmental variables are stored!
if (res ==
SetVariable("JOB",
(char*) evJOBValue.GetBuffer(3),
strlen(evJOBValue),
REG_EXPAND_SZ))
evJOBValue.ReleaseBuffer(-1);
if (res ==
SetVariable("SHOT",
(char*) evSHOTValue.GetBuffer(3),
strlen(evSHOTValue),
REG_EXPAND_SZ))
evSHOTValue.ReleaseBuffer(-1);
// propagate changes so that environment variables takes immediate effect!
if( SendMessageTimeout(HWND_BROADCAST,
WM_SETTINGCHANGE,
0,
(LPARAM) "Environment",
SMTO_ABORTIFHUNG,
10000,
&dwRet) ){
AfxMessageBox("Registry has been updated sucessfully!", MB_OK);}
else AfxMessageBox("Registry didn't update sucessfully!", MB_OK);
PROCESS_INFORMATION ProcessInfo;
STARTUPINFO StartupInfo;
ZeroMemory(&StartupInfo, sizeof(StartupInfo));
StartupInfo.cb = sizeof StartupInfo;
if(CreateProcess("Path to the exe file",
NULL,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&StartupInfo,
&ProcessInfo))
{
CloseHandle(ProcessInfo.hThread);
CloseHandle(ProcessInfo.hProcess);
}
else
{
AfxMessageBox("The process could not be started...", MB_OK);
}
CDialog::OnOK();
}
DWORD CSetEnvDialogDlg::SetVariable(char *name, char *value, DWORD valuelen, DWORD type)
{
HKEY h;
DWORD rc;
rc = RegOpenKeyEx(HKEY_CURRENT_USER, "Environment", 0, KEY_WRITE, &h);
if (rc == ERROR_SUCCESS)
rc = RegSetValueEx(h, name, 0, type, (unsigned char*) value, valuelen);
RegCloseKey(HKEY_CURRENT_USER);
return rc;
}
Xzaran
|
|
|
|
|
Have you single-stepped through each of the statements to see which one is causing the error? While I doubt it is related to the problem, you might want to consider changing strlen(evJOBValue) to evJOBValue.GetLength() . Also, if you changed the second parameter of SetVariable() to a LPCSTR , you could eliminate the (char *) cast, and the call to CString::GetBuffer() and CString::ReleaseBuffer() . When checking the return value from SetVariable() , are you intentionally using the comparison operator instead of the assignment operator?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hello David,
the problem is, that the error message occures with the child process, which is bought product I can't debug. Actually, now that I looked at the code project page again it is the same error message ymmace explained in his thread: Look for help!! About NTDLL.DLL problem~~. That's why I thought I might have missed something in my code. Maybe I have to free some memory I allocated with the pointers?
Unfortunately my knowledge about pointers is not so good.
But thanks for the advice about simplifying my code...I will try that.
Any more suggestions about the NTDLL.DLL problem?
Cheers, Xzaran
|
|
|
|
|
Xzaran wrote:
Maybe I have to free some memory I allocated with the pointers?
Since you showed no heap allocations, it would be hard to tell at this point.
If you run this other application all by itself, does the problem still occur?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
No, it runs perfect if its not called from my dialog application.
Where do I have to look to find the possible problem?
Xzaran
|
|
|
|
|
if (CreateProcess("Path to the exe file",
NULL,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&StartupInfo,
&ProcessInfo)) Have you tried different values for dwCreationFlags besides 0?
StartupInfo.cb = sizeof StartupInfo; Shouldn't you have parenthesis with this?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I tried out
CREATE_DEFAULT_ERROR_MODE
CREATE_NEW_CONSOLE
CREATE_NEW_PROCESS_GROUP
CREATE_SUSPENDED
DEBUG_ONLY_THIS_PROCESS
DETACHED_PROCESS
and
HIGH_PRIORITY_CLASS
but unfortunately none of them changed anything.
I set the parenthesis, thanks.
The error message tells me something like:
"The allocation 0x778cc641 shows to memory 0x00000180. "Read" couldn't run on memory."
Or similar( my Windows2000 is in a different language than english!).
Does that help getting closer?
Xzaran
|
|
|
|
|
MyApplication is disappearing when I try to use CFileDialog to get a file name to save contents.
This is not happening in case of Dubug version. And OS is win2000.
Any suggesstions.
Warm Regards,
KKR
|
|
|
|
|
Never seen this... how do you actually call CFileDialog? maybe your filter is not defined correctly... and that would explain why you have a different behaviour in debug and release...
|
|
|
|
|
Thanks for the Respose,
Following is the code
static char BASED_CODE szFilter[] = "INI Files (*.INI)|*.INI|All Files (*.*)|*.*||";
CString m_szCurrentFilePath;
CFileDialog obFDlg( FALSE, ".INI", m_szCurrentFilePath, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter, pApp );
obFDlg.DoModal();
Warm Regards,
KKR
|
|
|
|
|
OK a few things...
pApp is not a window... you should have AfxGetMainWnd()
and as for the extension I think your are meant to have "INI" not ".INI"
and I take your app does not use Unicode.
Let me know if does the trick!
|
|
|
|
|
Yeah,
In trial and error , I've kept pApp, but it holds only Parent window,
Reg Extn what ever it is ".ini" or "ini", its disappearing.
My application is not UNICODE one.
Warm Regards,
KKR
|
|
|
|
|
Well this is spooky and it is something I use all the time. Is your office built on an ancient indian cemetry or something?
One more stab in the dark, have you tried to initialise your m_szCurrentFilePath (to _T("")) or pass NULL instead?
Let me know if you do find out!
|
|
|
|
|
I have experience similar (but not identical) problems with CFileDialog based code when the file path string is incorrect. In such cases, the usual result is that the dialog fails to appear. My advice is therefore to verify that the lpszFileName parameter (3rd one) is correct. You could also try using an empty string instead, and see whether that produces different results.
Hope this helps.
|
|
|
|
|
|