|
HocusPocus235 wrote:
WinExec("Application.exe",SW_SHOWMAXIMIZED);
As WinExec() is for use with 16-bit Windows, why not use CreateProcess() instead?
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
si.cb = sizeof(si);
CreateProcess(NULL, "Application.exe", ..., &si, &pi); Now when you want to know about the process, just look at pi.hProcess .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks for the sugestions people CreateProcess worked a charm
|
|
|
|
|
well..... ihad done this a different way.....
u c .....windows cannot delete a file when itz running.....use that concept.....
first make extra copies(backup) of the exe in a different location.....suppose the file that u want to check is not running,and u check this by trying to delete this file using the other running application,if success in deleteing the file then the file that u were checking was not running,else if it couldnt delete it,it meanz itz running.....now suppose it wasnt running and by checking this file if itz running or not(by trying to delete method),the file getz deleted,so now replace the backup exe to the same location.....
thatz the idea,i used in one of my programz.....
(might soung stupid.....but it workz fine).....
hope this info helpz.....
Happy programmin....
cheerz.....
|
|
|
|
|
Enumerating the running processes is as easy and a hell of a lot safer.
You also can not delete an executable if it is read only!!
I would *NOT* recommend that people try to determine if executables are running in this way.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
well.....(just a suggestion;))afterall it workz!!!!!.....thanx for correcting me.....
Happy programmin bro.....
cheerz.....
|
|
|
|
|
In some instances, working is merely a symptom of the output. Many things might appear to produce a correct result but that does not mean they are correct.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi,
Look the MSDN documentation for following API's and structs
PROCESSENTRY32 struct and api's like CreateToolhelp32Snapshot,
Process32First,Process32Next etc.
you can use these set of api's to check the exe is running or not !
If you have patients wait for some days, i m putting the artical on this
issue !
Regards,
Vishal
|
|
|
|
|
I should create the dialog window (mfc) when hot key is pressed. All works fine, but at first time the dialog creates with a small delay and instantly later. How to speed up it first creation?
Thanks.
|
|
|
|
|
You could create this window when your app is idle and set it to be hidden first. Then you just make it visible when the user presses the hotkey.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi All,
Could anyone tell me with an example how to use the CRgn::GetRegionData()..?
TIA
regards,
Rajesh
|
|
|
|
|
Could someone tell me how to write a .ini file of an application to store some states of all controls in an application? Simply using CFile to write or there are some special classes to handle this? Thanks!
|
|
|
|
|
The
GetPrivateProfileXXX and
WritePrivateProfileXXX
functions do the job for you
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi, everyone:
Can someone provide a EZ way to change an individual text in a dialog? I knew that I can use CDC functions to realize that, but can I do this on a Static Control? To talk in detail, I wanna use SetWindowText() or SetDlgItemText( ) to change the text of a control containing some text string. And what should I do to change the reulting text? Or don't think about that, simply use CDC functions? Thanks!
|
|
|
|
|
Handle the WM_CTLCOLOR message.
In VS call the properties for the dialog, there you can set handlers for messages, in that list is a WM_CTLCOLOR message. Choose a function to handle this.
Write something like this in it:
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);<br />
CBrush *brush;<br />
brush = NULL;<br />
CWnd* pStaticWnd = (CWnd*)GetDlgItem(IDC_STATIC_STATUS);<br />
if(pWnd == pStaticWnd){<br />
pDC->SetTextColor(RGB(0, 0, 255));<br />
}
pStaticWnd = (CWnd*)GetDlgItem(IDC_STATIC_INFO_DOC);<br />
if(pWnd == pStaticWnd){<br />
if(lock_docstatus_text){<br />
pDC->SetTextColor(RGB(0, 100, 200));<br />
}
else{<br />
pDC->SetTextColor(RGB(0, 0, 255));<br />
}
}
pStaticWnd = (CWnd*)GetDlgItem(IDC_STATIC_INFO_SEND);<br />
if(pWnd == pStaticWnd){<br />
if(lock_sendstatus_text){<br />
pDC->SetTextColor(RGB(0, 100, 200));<br />
}
else{<br />
pDC->SetTextColor(RGB(0, 0, 255));<br />
}
}
return hbr;<br />
for more info check out msdn.
Hope this helps, good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
It didn't work....
But if the condition in if() changed to this form could work:
if( pWnd->GetDlgCtrlID() == IDC_STATIC_MY_STATIC )<br />
{<br />
pDC->SetTextColor(RGB(255, 0, 0));<br />
}
Anyway, thnks for your help.
|
|
|
|
|
ytod wrote:
To talk in detail, I wanna use SetWindowText() or SetDlgItemText( ) to change the text of a control containing some text string. And what should I do to change the reulting text?
You just answered your own question. Use SetWindowText() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DavidCrow wrote:
ytod wrote:
To talk in detail, I wanna use SetWindowText() or SetDlgItemText( ) to change the text of a control containing some text string. And what should I do to change the reulting text?
Miss one word "color":
And what should I do to change the reulting text "color"?
But I need to try what the previous post described first, thanks!
|
|
|
|
|
Using OnCtlColor() , or handling the WM_CTLCOLOR message, is the preferred method.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I need to insert a new line at the beginning of a text file but i don´t know how to do this without overwriting the first line. This is my code:
...
file.SeekToBegin();
file.WriteString(text);
...
I've also tried this:
...
file.SeekToBegin();
file.WriteString("\r\n");
file.WriteString(text);
...
but it doesn´t work. Could anyone help me? Thanks
Lucia
|
|
|
|
|
Do you have a valid file handle, do you have write-access to this file?
Check the return codes.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
It is not possible to 'insert' new data at the begining of the file. A solution for doing that is using a temporary file. In this file, you first copy the first line you need to insert, then copy all the data from the original file. When this is done, you take this data and copy it into the original file (erasing all it's previous contents).
|
|
|
|
|
I think allocating a buffer that's long enough to store previous data could also work.
|
|
|
|
|
Thanks for the reply. I have already thought of this solution but i searched the simplest one. Ok, i'll try using a temporary file
|
|
|
|
|
Be sure you have write access to the folder in which the temporary file will be created. If the file is not gigantic (e.g., 100MB or more), you could just read it into a heap-based buffer, write the new text to the file and then append the contents of the buffer. That's about as simple as it gets.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
is it possible to read icon (resource) info from an exe file directly without using resource functions such as ::FindResource()?
thx
includeh10
|
|
|
|