|
"COM2" is a constant null terminated string allocated somewhere by the compiler. It's reasonable to set a char * to point to its first character. But really it should be a const char * since the value of the string should not be changed.
Try writing pcCommPort = "COM3" , now you're setting the value of pcCommPort to the address of "COM3". Previously you were trying to set what pcCommPort pointed at (in this case presumably the constant string "COM2") to your new string. Which isn't what you intended.
Paul
|
|
|
|
|
Thanks Paul -- that was it! I don't know why I didn't catch it myself.
Still looking for some clarification and answers about my original post... your help is greatly appreciated.
|
|
|
|
|
I'm now down to the point where I have the code written for everything up to where I understand -- meaning, the WaitCommEvent part is the only part that needs completing.
Any help with this?
|
|
|
|
|
How can I check if application X is running ?
I’m writing an Update tool for my application and I need the program to
wait until the application quits before continuing.
I don’t think I can use FindWindow since the Title text of the application is not static.
/Mathias
|
|
|
|
|
is it ur own app? if so use Mutex
I want to change Myself..Can u help me?
|
|
|
|
|
Mathias S wrote:
I’m writing an Update tool for my application and I need the program to
wait until the application quits before continuing.
Does the Update tool start application X? If so, WaitForSingleObject() can be used.
Mathias S wrote:
I don’t think I can use FindWindow since the Title text of the application is not static.
Do you know the class of the window? If so, FindWindow() can still be used. In any case, it's not a 100% reliable function in that it relies upon a static caption or class, and it can introduce a deadlock situation.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Is there a sample code which demostrates how to wrap an executable with another exe program. Uses for software protection, etc
Thanks
|
|
|
|
|
See if this article is of any help.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
There is an article on CP that put it into the resources then extract it and run it.
Another that calculates a CRC on the data and check it each time it runs.
To tell you the truth, whatever you'll do it will be crackable. The idea is to make it more dificult to crack.
Check some anti-debugging, anti-cracking and anti-softice.
Then think of packing your exe with one of the free or comercial packers (teLock, petite to name a few)
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hello,
If i Debug my project with the VC++ 6.0 debuger I get no errors, but if I use BoundsChecker I get all kinds of errors, some of which I will post here, so someone out there may tell me if this is something with BoundsChecker or with my code.
First snippet (using mutex to prevent more than one instances of my program)
In the header of my CWinApp derrived main class:
HANDLE m_hMutex;
In the implementation (cpp) file of my CWinApp derrived class:
In InitInstance:
m_hMutex = CreateMutex(NULL, TRUE, _T("somename"));
if(!m_hMutex || GetLastError())
{
CString strMessage, strTitle;
strMessage.LoadString(IDS_APP_MESS1);
strTitle.LoadString(IDS_INFORMATION);
MessageBox(NULL, strMessage, strTitle, MB_OK|MB_ICONERROR);
return FALSE;
}
in the ExitInstance function
if(m_hMutex)
{
ReleaseMutex(m_hMutex);
}
for this code I get no errors under the standard debugger and I get error from BoundsChecker: "Resource leak: allocated by CreateMutexA.....HANDLE:0x00000718
Next I have the following events occuring:
CMyDlg::OnInitDialog
CMyDlg::DestroyWindow
where in the CMyDlg::OnInitDialog I have the following code fragment:
hBitmap = NULL;
hModule = NULL;
hModule = LoadLibrary(_T("resource.dll"));
if (hModule)
{
hBitmap = ::LoadBitmap(hModule, MAKEINTRESOURCE(1000));
ASSERT(hBitmap != NULL);
m_bmp.SetBitmap(hBitmap);
}
and finally at CMyDlg::DestroyWindow I have:
if(hBitmap)
VERIFY(::DeleteObject(hBitmap) != 0);
if(hModule)
VERIFY(FreeLibrary(hModule) != 0);
The error I detect using BoundsChecker is
CIShieldView::OnItemNew
CEntryDlg::OnInitDialog
Entry::DestroyWindow
First-chance exception in IShield.exe (KERNEL32.DLL): 0xC0000005: Access Violation.First-chance exception in IShield.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
What am I doing wrong?
Thanks in advance
|
|
|
|
|
Deian wrote:
What am I doing wrong?
Assuming that BC is 100% accurate, or that it is reporting only on your code. It's been many years since I used BC, but I do remember that it reported a bunch of false positives, and it also reported on internal MFC code (when I obviously was only concerned with code that I had written).
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Well, most of the errors are MFC errors, but I get these, and I think that it will not be difficult for somebody outhere to tell me whether these errors are in my code, or some MFC stuff, and a possible workaround if any.
Thanks, still waiting....
|
|
|
|
|
and also any comments on these first - chance exceptions?! what is the cause for them?
|
|
|
|
|
Deian wrote:
what is the cause for them?
It could be any number of things. Searching MSDN for "first chance exception access violation" yielded a bunch of hits, all of which show various reasons.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
|
I have been using BC since the DOS/Win31 days and prefer not to compile and run any program in debug mode without it. Some of the things BC reports as errors may not be, the most common example is invalid argument. Some times it is correct, but other times it is reporting a NULL or some other value as incorrect. In the case of NULL, it has failed to take in account the the function description specifies a NULL parameter is valid. Once in a while it will report an interger value is invalid because it is not in a known range, this is not always correct. If it is reporting memory leaks and resource leaks (watch out), because it is almost always correct. First-chance exceptions (Access Violation) you see in the debug pane are usualy an MFC thing and may mean nothing. Normaly if you have commited an access violation, you will know it; because the program will up-chuck and the debugger will break on offending line (not normaly where the original violation occured).
INTP
|
|
|
|
|
Well, as far as the mutex problem. You need to call CloseHandle(m_hMutex) to close the mutex handle. That is the reason for the resource leak.
Kelly Herald
Software Developer
MPC
|
|
|
|
|
In the first case, ReleaseMutex only releases ownership, it does not delete the mutex.
if (m_hMutex)
{
ReleaseMutex(m_hMutex);
CloseHandle(m_hMutex);
}
For the second problem, you are loading hBitmap, then setting it in a control, but then deleting that bitmap. drop the DeleteObject(hBitmap) and modify the first section as follows:
if (hModule)
{
HBITMAP hBitmap = ::LoadBitmap(hModule, MAKEINTRESOURCE(1000));
ASSERT(hBitmap != NULL);
m_bmp.SetBitmap(hBitmap);
}
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I'm writing a dialog based app and when I created it I didn't enable active x support now I'm wanting to add a rich edit to the dialog, but my program wont run. I added the AfxEnableControlContainer () to the InitInstance function, but when I call DoModal () on the dialog it's returning -1. I walked through the code and it never seems to return any error from any of the intermediate functions that DoModal calls. Is there anything besides AfxEnableControlContainer () that I need to call/do in order to enable active x controls? I know the control (rich edit) is the problem because when I remove it the program runs fine. Thanks.
- Aaron
|
|
|
|
|
Got any trace output?
Typically you'll see messages in the Output window which can help with debugging, if it's due to an ActiveX control.
The rich edit box is not an ActiveX control. It's a common control. You need to call AfxInitRichEdit if you're going to use one in a dialog box.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
My mistake. I thought it was an ActiveX control because there was trace output when I didn't have the AfxEnableControlContainer that said to add it. I assumed (falsely it would seem) that it meant the rich edit was an ActiveX. Thanks for the help.
- Aaron
|
|
|
|
|
Hi Aaron,
You are obviously adding the RichEdit control from the Controls toolbar. If this is the case then you need to do the following for it to work:
BOOL CNoactivexApp::InitInstance()
{
AfxEnableControlContainer();
#ifdef _AFXDLL
Enable3dControls();
#else
Enable3dControlsStatic();
#endif
AfxInitRichEdit();
CNoactivexDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
}
return FALSE;
}
also make sure that #include <afxcmn.h> is listed in your stdafx.h
As a side note, this isn't an ActiveX control, if you go to the dialog resource and right-mouse "Insert ActiveX control...", select "Microsoft Rich Textbox Control 6.0" then this WILL use the ActiveX control and you DONT need to perform the AfxInitRichEdit(); call.
Hope this helps,
Andy
|
|
|
|
|
Guess I should have done some reading on the rich edit instead of just assuming that it was an ActiveX control. Thanks for the code example. Quick question...Do I still need to be calling AfxEnableControlContainer if I'm not using any ActiveX controls? Thanks for the help.
- Aaron
|
|
|
|
|
Hi Aaron,
No you don't need to call AfxEnableControlContainer unless you want to support containment of ActiveX objects. My advice would be to add it anyway - YOU may not need it now but the developer that comes along after you may need it to enhance your app (save him going through the same hoops).
If you do leave it in, don't forget to include #include <afxdisp.h> in your stdafx.h file.
Cheers,
Andy
|
|
|
|
|
Thanks for all the help Andy.
- Aaron
|
|
|
|