|
Well, maybe SetErrorMode can be of help in supressing system error messages.
It seems that the exception is not being catched...
Didn't you say in your previous post it was working?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hello again...
Sorry I've been interrupted during the test and what I've been only capable to see is that the thread was not getting hung.
Althought the thread is not getting hung I've placed some breakpoints inside the catch statement and the program flow never goes through them...
It is strange... I've taken a look at the MSDN and all the exceptions that can happen are the ones that you haev in your list... but the catch is not getting them...
Thank you in advance...
PS: I don't want to bother you with too much questions... please feel free to stop answering me when you consider that that's enough...
|
|
|
|
|
OK, now I think I know what your problem is. Those system message boxes saying things like "No diskette in drive A:" are what you want to supress, right? If so, then exceptions (SEH or the other) have nothing to do with the issue. The following sample shows how to supress the message box in a CopyFile opreation, the function merely returning FALSE as the result:
int main(void)
{
UINT error_mode=::SetErrorMode(0);
::SetErrorMode(error_mode|SEM_FAILCRITICALERRORS);
BOOL b=::CopyFile("A:\\pepe","C:\\pepe",FALSE);
return 0;
} Hope this helps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hello again...
Yes, it should have worked...
I've remembered that I tried this before when I've seen a variable declared at the beggining of the thread (UINT uiErrorModeANT = 0; ) that was the one that I had used in order to set the new error mode and at the last point of the thread flow I used it to return the error state at it's original state.
Some time ago I decided to left that function without that security because of I had not enough time...
- I had tried to use the try/catch and it didn't worked because it hung the thread (I suppose that it was because I didn't know how to make it work).
- I had tried setting the error mode to "0 | SEM_FAILCRITICALERRORS" too and it didn't worked too.
- Now I was wondering about SEH, and after your help, I've seen that the exception raised wasn't captured by the SEH...
I don't know what more to search or to do... but I must solve that because is a weak point of my program and it can make possible to enter to the OS without permission.
And I would like to leave the messages that appear when I take the floppy out from the drive, but then the taskbar appears only for a while, but it give access to it to the user; this is a very big problem for me because I write apps that must start at the beggining and end shutting down the PC...
NOTE:
It seems that the rightest approach was the try/catch, at least it blocked the message, the only problem is that I don't know why it blocked the thread too...
Can I send you the thread code? (it's a small function)...
Thank you in advance...
PS: Before sending you the code I'll wait for your answer... meanwhile I'll continue trying to solve it.
|
|
|
|
|
Hello again,
I'll finish meeting you at your office...
That's working now...
The changes have been:
try
{
iRetornOperacioCopia = CopyFile(csFullPathOrigenPrograma, csFullPathDestiPrograma, FALSE);
}
catch(...)
{
iRetornOperacioCopia = 0;
}
and I suppose that the program flow should be:
1. The program tries to make the copy...
2. The program fails copying because there's no disk.
3. The program enters into the catch clause and assigns 0 to iRetornOperacioCopia.
4. The program flow continues outside the catch clause.
What has surprised me is:
1. Of course that it is working changing the (CException *e) for a (...)
2. That the code flow never enters inside the catch clause.
By the way I won't send you the thread code...
Thanks a lot for all your help...
|
|
|
|
|
Also just a guess.
From MSDN:
<quote>
Compiler Error C2712
cannot use __try in functions that require object unwinding
You cannot have objects that require unwinding in a function with structured exception handling.
To avoid this error message, compile using the /GX- option.
The error can be avoided when using the /GX option by not having local variables or parameters with types that have destructors in a function that uses structured exception handling (SEH). Furthermore, SEH cannot be used in constructors or destructors if using /GX. Code that requires SEH can also be moved to another function in order to avoid the error.
</quote>
I would think you could eliminate the problem by using a TCHAR array instead of CStrings, that way there are no destructors to be called.
I think the problem is that if an exception is thrown, the CString destructor is unable to execute, resulting in a memory leak (at least the compiler sees it that way).
HTH
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Hello,
First of all...
Sorry, I've been out of my office for some days...
Won't that option have any secondary effect over the program?
Thank you in advance.
|
|
|
|
|
I have some controls in a CFormView class which should only be visible when some button control is pushed. In the button click event, I added the code to display the controls as follow:
GetDlgItem(IDC_STATIC_FY)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_EDIT_FY)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_BUTTON_PLUS_FY)->ShowWindow(SW_SHOW);
It got compiled OK. But when I ran the application I got an assertion fail error message. I checked with the MSDN document, GetDlgItem is a member function of a CWnd class. CFormView is a CWnd class, right?
-Elizabeth
Eilzabeth
|
|
|
|
|
|
Either the controls are null or (i.e not initialised) or you are doing something noddy wrong like calling from the wrong window. If they are null, try adding a member variable for each resource id, and a DDX routine for each one. Make sure you are not calling GetDlgItem() before OnInitialUpdate();
"Life begins at 140"
|
|
|
|
|
You are right. I called a _itoa() function right before the GetDlgItem functions. I forgot to give the char variable an extra byte for the null char. That caused all sorts of problems. Thanks you.
-Elizabeth
Eilzabeth
|
|
|
|
|
I am importing OIP22.TLB in one of my header file. I am trying to connect to a oracle database which is on unix box through by VC++ application.
The following is the code I am using:
BSTR bstrDb = m_strOraDb.AllocSysString ();
BSTR bstrUser = m_strOraUser.AllocSysString ();
m_pOraDatabase = m_pOraSession->GetOpenDatabase( bstrDb, bstrUser, ORADB_DEFAULT);
m_strOradDb , m_strOraUser are Const CString
Values in m_strOraDb and m_strOraDb are : "omst", "oms/oms" (Our database name, userid/password, ORADB_DEFAULT = 0)
From above it goes into this routine of OIP22.TLI file:
#pragma implementation_key(36)
inline IDispatch * OraSession::GetOpenDatabase ( BSTR dbname, BSTR connect, long options ) {
IDispatch * _result;
_com_dispatch_method(this, 0x60010002, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&_result,
L"\x0008\x0008\x0003", dbname, connect, options);
return _result;
}
It fails just before return_result saying:
First-chance exception in MYAPP.EXE (KERNEL32.DLL): 0xE06D7363
|
|
|
|
|
ravi28 wrote:
First-chance exception in MYAPP.EXE (KERNEL32.DLL): 0xE06D7363
That is a Microsoft C++ exception. Set your debugger to always break on this exception and you should find out where it's coming from.
|
|
|
|
|
Hi,
Bear with me, I am a actually a VB guy, I went to exceptions and selected stop always for this error code. I know that it is breaking when I call a method of OIP22.TLH file, I am confident that am sending the right parameters but it still fails with this exception. Is this get to do with versions of Oracle installed on my machine or nothing??? What is the path you would suggest me to go with????
ravi
|
|
|
|
|
Hi,
Bear with me, I am a actually a VB guy, I went to exceptions and selected stop always for this error code. I know that it is breaking when I call a method of OIP22.TLH file, I am confident that am sending the right parameters but it still fails with this exception. Is this get to do with versions of Oracle installed on my machine or nothing??? What is the path you would suggest me to go with????
ravi
|
|
|
|
|
Hello,
How can I get the size of physical and virtual memory used by a process?
Thanks, Alma
|
|
|
|
|
alma wrote:
How can I get the size of physical and virtual memory used by a process?
Physical, not from Win32. Virtual, GetProcessWorkingSetSize.
|
|
|
|
|
I found the following solution:
<br />
DWORD dwProcessID = GetCurrentProcessId();<br />
HANDLE hProcessHandle = OpenProcess( PROCESS_QUERY_INFORMATION, FALSE, dwProcessID);<br />
<br />
PROCESS_MEMORY_COUNTERS p;<br />
GetProcessMemoryInfo(hProcessHandle , &p, sizeof(PROCESS_MEMORY_COUNTERS);<br />
logit("Using [PM - %d] [VM - %d]", p.WorkingSetSize, p.PagefileUsage);<br />
It needs 'psapi.h' (and 'psapi.lib' if you want to load 'psapi.dll' statically).
-Alma-
|
|
|
|
|
In my program I need to remove the everyone security group and another one in it's place.
|
|
|
|
|
I have an MDI application with multiple view classes. Now I want to use one of these view classes in an SDI application. The problem is that in the OnInitialUpdate() function I call Create(...) for some ownerdraw buttons. When I use the class in SDI it will call OnItialUpdate() several times for the same view, for example every time File Open or File New is selected. This crashes the program as it tries to create buttons that allready exist.
What is the simplest method to avoide multiple calls to OnInitialUpdate()? Or, where else should I call Create() ?
To me it seems ridiculous to call OnInitialUpdate several times, the name is an indication that it is a one-off event
Regards, Haakon S.
|
|
|
|
|
How about calling your Create() in in the view's OnCreate() ?
|
|
|
|
|
I tried OnCreate(), and it didn't work. But mind you, it may have failed not because of the buttons Create() functions, but because of the next piece of code, LoadBitmap(). I got an ASSERT because hWnd==NULL. It is a general problem that I want to do a lot of initialisation after the view is created, but before it is visible. And I want to do it once.
Haakon S.
Joggers live two years longer. But those two years they spend jogging.
|
|
|
|
|
As long as your window isn't created hWnd is NULL. Thus you should first call the base class' OnCreate(). When finished, your windows hWnd should contain a valid handle - if not, I'm not certain what to do .
|
|
|
|
|
I've checked it again, and yes, maybe you are pointing in the right direction . But I'm not home free
I've got some CStatic members in the resource template (my view is CFormView), identified as IDC_TOP and IDC_BOTTOM. They are subclassed into CStatic derivatives for color and blinking:
m_stTop.SubclassDlgItem(IDC_TOP, this);
m_stBottom.SubclassDlgItem(IDC_BOTTOM, this);
This works fine in OnInitialUpdate(), but not in OnCreate() . Next time OnInitialUpdate() comes back, I've got an error.
Joggers live two years longer. But those two years they spend jogging.
|
|
|
|
|
Here's a hack:
add a member variable to your view class
BOOL m_bOnInitialUpdateRan;
Set it to false in your view's constructor
m_bOnInitialUpdateRan = FALSE;
and then in OnInitialUpdate only create your controls if it is FALSE. Be sure to set it to TRUE afterwards.
if (!m_bOnInitialUpdateRan)
{
m_bOnInitialUpdateRan = TRUE;
}
Note: This is not tested, so give it a try. May work, may not
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|