if you know the title of that window, use this: LPSTR name="the_window_title"; HWND hWnd = ::FindWindow(NULL,name); ::SendMessage(hWnd, WM_CLOSE, 0, 0);
Peak
Posts
-
Which is the simplest way to close an application? -
Keep console from disappearing::WinExec ("cmd.exe /c tracert X.X.X.X & pause", SW_SHOWNORMAL/* not SHOW_NORMAL ;) */); on win95/98/me I think you need to use command.com instead of cmd.exe
-
How to send data to ethernet if Mac Address is knownyou mean you have the MAC address of destination machine? or you have multiple ethernet cards on your machine and want to use the one that maches that MAC address? if your answer is the destination machine: you have to use WinPcap(http://winpcap.polito.it/) also take a look at here: http://www.csee.usf.edu/~christen/tools/rawstuff.zip but be carefull. you are going too low-level... ;)
-
atoi and cstringatoi starts translation first by removing seperator characters(like space) from the string, looking for the first character. if it is a digit, it starts translating it into an integer, but if not, it returns zero. you can use it like this: LPSTR ss="4 cars"; int x=atoi(ss); if(x==0 && strcmp(ss,"0")){ // the input is probably not a real zero, // it's an error }
-
How to call interrupt functionif you are using windows 98 or 95 you can call interrupts, but on xp & 2k no way there from user mode applications! that function IoConnectInterrupt is for device drivers, and does not do what you need. anyway, you can use some device drivers like ntport to have direct access to ports, then you can use direct port access and so you can read CMOS. ( so no need to use the interrupt, but you have to know how to read CMOS using in/out OPs) anyway it's a long way. if you have any other alternatives, I recommend you to review them, maybe you are going the hard way...
-
How to get the full path-name of 'My documents' in different OS?use SHGetSpecialFolderPath
-
How to set the original size of a window?you can enumerate resources of the executable containing that dialog box if the window is a dialog which is created from resources. take a look at this API documentation : EnumResourceNames() but to identify which resource corresponds to that window you need to compare window names, or if the name is modified, you need to compare its contents. but about a simple API that does the job, at least I haven't heard of.
-
argv argc and buffer over-run HACKany Windows application uses GetCommandLine() API to receive a pointer to its command line arguments, or uses a parameter which is passed to its WinMain function that points to the program command line. After that,if you have a main function, C Run-Time Libraries (CRT) formats the arguments, seperates them, and counts them and then sends them to your main function using argv and argc. if you use MFC, it has some wrappers around this command line(but you can use __argc & __argv which are globally defined),anyway the WinApp::m_lpCmdLine contains the raw command line. Up to here no stack overflow or other flaws exist. now it depends on your code to how to deal with these arguments. if you do something like: char myparams[100]; strcpy(myparams, AfxGetApp()->m_lpCmdLine); or even: printf(AfxGetApp()->m_lpCmdLine); then you have to review your old codes. ;)
-
Systrayyou need to start your MFC modal dialog program with a hidden dialog, and the only way I found for this problem was to call ShowWindow(m_hWnd, SW_HIDE) in one of WM_NCPAINT or WM_PAINT message handlers. There is another way for this problem, but needs a little more modification of your program. The normal way would be to uncheck WS_VISIBLE style in resource editor, and start you dialog using CreateDialog , then make a message loop there by calling AfxPumpMessage in a loop like this: CMyDlg mydlg; mydlg.Create(IDD_MYDIALOG);// that IDD_MYDIALOG is // the dialog resource id, // you can find it in your // dialog class definition // (TrayIco.h as you said) // in a line like this: // enum { IDD = IDD_MYDIALOG }; // if you wanted to show dialog window // ShowWindow(m_hWnd, SW_SHOW); while(AfxPumpMessage()); // loop till the QUIT // message comes.
-
How to call interrupt functionthe programs you run are in User Mode( ring-3 applications, you can read more about this in intel processors specifications). They cannot run INT commands( and many others, they are called priviledged op codes, see the reference above). And if anyway you could do it (I mean if you write a device driver and call the above INT command), many INTs don't have the functionality you have seen before in old days of real-mode OSs like DOS.
-
About socket input queue.hi you can use ioctlsocket function to find out how much data is available to read.
-
regsvr32 failedhi have you traced the program execution? does it get to the pFunc() calling? does it come out of that call back to your program?
-
Dialog Windows Hidden Problem :: MFCHi maybe you just have to overried OnOK() and OnCancel() of that dialog box classes. cause when you press ENTER OnOK() will be called and the window destroys itself. the same thing happens for ESC and OnCancel()
-
"DestroyWindow" ---- Error!!!!hi are you trying to destroy a window in that window's class deconstructor? I think when deconstructor is called, the window is already destroyed, so no message can be sent to it,like WM_DESTROY( which invokes OnDestroy).
-
regsvr32 failedhi have you tried this? nRetCode = WinExec("RegSvr32 /u \"C:\\Program Files\\RealTime7\\QueryGenAlpha\\QueryGenAlpha.dll\"", SW_SHOW);
-
entry question, thankshi maybe you havn't called TranslateMessage in your message loop. you know what's message loop, yes? any way this is a simple message loop: while(GetMessage(...)) { TranslateMessage(...); DispatchMessage(...); } hope it helps:)