|
It works like a Charm everytime i do it you must be doing something wrong
check the MSDN Online for article no 105150
or
click me[^]
if you want ur application's resizing stopped try to handle mainframe's onsize or mouse click events(NC)
if you don't want to use Splitter window at all then create a CView and in the CView create two child windows side by side (handle all the sizing in OnSize event)
u'll get the desiered results
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
I overrode the onsize event, that seemed to do the trick, thanks.
|
|
|
|
|
Why not have the selectable tiles as a toolbar? (unless you have thousands of different tiles...)
Roger Allen - Sonork 100.10016
If your dead and reading this, then you have no life!
|
|
|
|
|
Hello to anyone who is willing to put a little thought in this.
I am in a quite hopless position right now.
The problem is this:
Suppose that there is a program that is running under Windows 95, 98 or ME, and this program malfunctions and freezes at some point. An external process (another program), learns this (
via means of a common bit in the LPT1, or a memory location being written periodically with '1' or '0' , so that the 'external watchdog program' gets the changes and knows if the program is still alive or not).
This, under Microsoft C++, would naturally involve CreateProcess or ShellExecute API calls to spawn the process and TerminateProcess to kill it. The problem is that under testing, when I terminate and re-spawn the process at regular 20s. intervals, after a while (it may be a few minutes up to half an hour, i.e. from 10 - 200 re-spawns), I get the Pop-Up Window
"Windows cannot find xxx.xxx. Please make sure the file exists e.t.c."
The weird thing is that CreateProcess API returns succesfully
and the GetLastError function is equal to 0, i.e. no error!
This happens when I run my code under Windows 95, 98 or ME.
Under Windows XP and for 12 hours consecutivelly the program runs fine. What could be the issue here?
**Note that both processes are console applications.**
I also tried putting a significantly long wait between the kill and the re-spawning (e.g. 13 seconds) but to no avail.
Something gets corrupted at some point but I have not been able to trace what. I do not think memory leaks is an issue in this case as the program is fairly simplistic and I close all handles normally.
I post some sample code below:
#include "stdafx.h"
#include "GetProcessID.h"
#include <tlhelp32.h>
#include <conio.h>
#define Debug true
unsigned char bit;
void killTheOther();
void RebootTheOther();
PROCESS_INFORMATION ProcessInfo;
STARTUPINFO StartupInfo = {0};
HANDLE theHandle;
int main(int argc, char* argv[])
{
UINT nactual = 0;
unsigned char temp = '0';
int SetWaiting = 0;
SetConsoleTitle("Stupid");
HANDLE Done = CreateEvent(0, FALSE, FALSE, 0);
// ensure window title has been updated
// look for newWindowTitle
Sleep(40);
HWND hwndFound = FindWindow(NULL, "Stupid");
// If found, hide it
if ( hwndFound != NULL){
//ShowWindow( hwndFound, SW_HIDE);
}
CloseHandle(hwndFound);
StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow = SW_SHOW;
if (!(CreateProcess("C:\\2.exe", NULL, NULL, NULL, FALSE,
CREATE_SUSPENDED | CREATE_NEW_CONSOLE, NULL, NULL,
&StartupInfo, &ProcessInfo))){
printf("Could not start process..., beacause:%d \n",
GetLastError());
theHandle =NULL;
}
else {
ResumeThread(ProcessInfo.hThread);
if (Debug)
printf("Process is started...\n");
theHandle = ProcessInfo.hProcess;
}
while(true){
bit = '0';
temp = bit;
if (Debug)
printf("Checking status...\n");
if (temp == bit){
SetWaiting++;
}
else{
SetWaiting = 0;
}
if (SetWaiting > 2){
printf("Here...\n");
if(theHandle != NULL){
killTheOther();
Sleep(10000);
RebootTheOther();
}
else{
printf("The han is NULL\n");
}
SetWaiting = 0;
}
WaitForSingleObject(Done, 10000);
}
return 0;
}
void killTheOther(){
TerminateProcess(theHandle, 0);
CloseHandle(theHandle);
theHandle = NULL;
}
void RebootTheOther(){
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);
if (!(CreateProcess("C:\\2.exe", NULL, NULL, NULL,
FALSE, CREATE_SUSPENDED |
CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo,
&ProcessInfo))){
if (Debug)
printf("Could not start process...\n");
theHandle = NULL;
}
else {
ResumeThread(ProcessInfo.hThread);
if (Debug)
printf("Process is started...\n");
theHandle = ProcessInfo.hProcess;
}
}
Sorry about my English
|
|
|
|
|
When TerminateProcess Terminates a Process it Doesn't terminates them Nicely , it Kills the Process then and there
so ur application doesn't get a chance to free resources (handles or other stuff) .
you would imagine that under such situation something is bound to be a miss if you are killing and spawning 200 times
you could try to create the new process without a console
that might do the trick (i.e without CREATE_NEW_CONSOLE )
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
No I am afraid it doesn't work without the
CREATE_NEW_CONSOLE MACRO either. I have tried pretty much everything. Even different
API's like ShellExecute e.t.c.
I agree with you it must be something to
do with TerminateProcess, but there is no
other way, is there? I mean ExitProcess
just terminates the process/thread where
it is called from. Is it possible to terminate a child process via means other than the TerminateProcess?
|
|
|
|
|
If you have to Terminate a Process Cause it is Hanged up , then there is no other way but to Terminate the Process except for calling TerminateProcess
but i can't see that happening 200 times
i think you need to rethink ur app design
if you want to terminate an application then you can use Events (SetEvent) to signal a termination request.
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
Well if the program frezees there is no way it will respond to a terminate signal.
Thanks anyway though!
|
|
|
|
|
hi all,
i m generating a log file for network printer in win 2000 .
when i did not set any user name & password ,the log file was generated successfully.
but when i set the username (administrator) with blank password and then when i m running the application , it was unable to create log file for printer.
is it registry problem.
shall i go to registry ???? to check ?
if so what is the registry path to set the user name & password as my program reads the username from registry.
please help.
skpanda
|
|
|
|
|
|
I get the following error, after i complie from release mode to debug mode, I aslo go for full rebuild, but still i
get the below stuff,
CAN any one explain me what this error is and how to resolve this error!!!
Linking...
LINK : LNK6004: Debug/MMCt.exe not found or not built by the last incremental link; performing full link
LINK : error : Internal error during ReadSymbolTable
ExceptionCode = C0000005
ExceptionFlags = 00000000
ExceptionAddress = 004622E0
NumberParameters = 00000002
ExceptionInformation[ 0] = 00000000
ExceptionInformation[ 1] = 0059F218
CONTEXT:
Eax = FFFFFFFF Esp = 0012E6BC
Ebx = 00000002 Ebp = 0059DE98
Ecx = 032E0164 Esi = 00000271
Edx = 00000BB4 Edi = 403EF0CC
Eip = 004622E0 EFlags = 00010206
SegCs = 0000001B SegDs = 00000023
SegSs = 00000023 SegEs = 00000023
SegFs = 00000038 SegGs = 00000000
Dr0 = 0012E6BC Dr3 = 00000002
Dr1 = 0059DE98 Dr6 = 032E0164
Dr2 = 00000000 Dr7 = 00000000
Error executing link.exe.
Tool execution canceled by user.
/* and i never canceled the execution but still i get "Tool execution canceled by user." WHY?
|
|
|
|
|
What version of VC sre you using ?
try to complie on another machine
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
thanks,
I am using VC 6.0/Win2000 and P-3 with 256 RAM, but why do i get this error?
|
|
|
|
|
While Compiling ur Program the compiler Screwed up !
check ur project settings
are you using any external lib files , check them
and try it on another PC
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
finally,
I happen to solve it in different fashion,
I delete debug version, copied the release version and checked all the option for debug and it worked, its pathetic.
regards
Balkrishna talele
|
|
|
|
|
Well this may be almost a decade too late but in case anyone else is experiencing this problem, I found the solution by changing code optimisation settings from Max Speed to Default in the C++ tab of VC6.
|
|
|
|
|
thanks for the answer, even though late not an issue, but it is logical answer, once again thanks
regards
Balkrishna Talele
|
|
|
|
|
Hi,
I have already posted this question on 17Dec and thankfully I got the reply from one Mr.Steve S, as well.
Just to recall, I need to start an SQLSERVERAGENT service in a system through program.
As said in that reply I implemented it successfully by using the LSA (Local Storage Authority) subsystem, from LsaOpenPolicy(), AddAccountRights() etc . Thnx....
But now the problem is,it is not effective in WindowsXP os. It fails in that operating system(I am not able to start the SQLSERVERAGENT service in WindowsXP). How to resolve it?The thing that I implemented is only for WindowsNT,2000.
How to make it work in WindowsXP?
thnx....
AK.
********
|
|
|
|
|
Nobody knows how to solve this problem??
|
|
|
|
|
Alright, I've managed to get buttons and all that working just fine, but I can't figure out how to get just a bitmap in the toolbar... In the google toolbar, for example, they have that lovely google logo over a button... I'd like that, but without the button. I've even gone so far as to make a button, and make it TB_INDEFINITE (or whatever it is, I'm not looking at my code), but I don't want it greyed out like that. I want it full color, but not clickable at all. I mean, I can have a button, but I don't want it to "click". Any thoughts, anyone?
|
|
|
|
|
Vermithrax wrote:
Any thoughts, anyone?
Custom draw on a separator sounds like your best bet. Alternately, you could float a static control over a separator.
Zno one puts flowers on a flower's grave
|
|
|
|
|
Hi,
I have following questions:
1. How do I create a directory in MFC?
2. When my application exists I want to delete the directory. How to do that?
3. In the directory I want to keep a feh html files. Users can look at the htmls when the application is running. When the applications exists I want to do the following
a) check any of those html files are open...How?
b) close them ...how?
c) delete them...how?
e) delete the parent directory.
Please advise.
|
|
|
|
|
|
|
hey well This can be done very easy. Just u make use of the system(command)
This system function is used to execute the dos commands. So u have to specify like system("md directoryname"); This will execute the dos command so that ur directory would created to delete do the same. to open the file just use _open to read or write the file just use _read or _write. I hope u better refer the msdn where u could be clear man. Just try this i hope this would be helpfull for u.
Bye .....
Shanmuga Sundar.V
|
|
|
|