Click here to Skip to main content
15,916,188 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Bits and bytes handling Pin
John R. Shaw28-Mar-03 18:58
John R. Shaw28-Mar-03 18:58 
QuestionHow hide Main Menu Pin
jeremysay24-Mar-03 23:56
jeremysay24-Mar-03 23:56 
AnswerRe: How hide Main Menu Pin
Simon.W25-Mar-03 0:31
Simon.W25-Mar-03 0:31 
GeneralRe: How hide Main Menu Pin
jeremysay25-Mar-03 2:06
jeremysay25-Mar-03 2:06 
GeneralCstring Pin
wow999924-Mar-03 23:42
wow999924-Mar-03 23:42 
GeneralRe: Cstring Pin
Christian Graus24-Mar-03 23:48
protectorChristian Graus24-Mar-03 23:48 
GeneralRe: Cstring Pin
Rage25-Mar-03 0:04
professionalRage25-Mar-03 0:04 
GeneralCreateProcess strange behaviour?! Pin
Enis24-Mar-03 23:28
Enis24-Mar-03 23:28 
Hello all!
Here is some "strange" behaviour of CreateProcess (or winword, I don't know)
I wanted to launch winword from my application and be notified when the user close the session I opened, so I used CreateProcess and WaitForSingleObject.
Here is the code sample from MSDN:

<br />
SECURITY_ATTRIBUTES sec;<br />
sec.bInheritHandle = FALSE;<br />
sec.lpSecurityDescriptor = NULL;<br />
sec.nLength = sizeof(SECURITY_ATTRIBUTES);<br />
<br />
STARTUPINFO si;<br />
::ZeroMemory(&si, sizeof(STARTUPINFO));<br />
si.cb = sizeof(STARTUPINFO);<br />
PROCESS_INFORMATION pi;<br />
<br />
//notice the 2 slashes after winword.exe<br />
if(::CreateProcess(NULL, <br />
  "C:\\Program Files\\Microsoft Office\\Office\\winword.exe / / C:\\STPMesagElec.doc", NULL,NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi)) <br />
{<br />
  // Wait for Word to become Idle.<br />
  WaitForInputIdle(pi.hProcess, 3000);<br />
  WaitForSingleObject(pi.hProcess,INFINITE);<br />
}<br />
else {<br />
  int err = GetLastError();<br />
  ::MessageBeep(0);<br />
  ::MessageBox(NULL, "CreateProcess() failed.\nCheck Path for WinWord.Exe.",<br />
"Error", MB_SETFOREGROUND);<br />
<br />
  return;<br />
}<br />
<br />
::CloseHandle(pi.hThread);<br />
::CloseHandle(pi.hProcess);<br />


Now, the result:
- If I use CreateProcess as above, but without the 2 slashes, it works only when there is no other instance of Word already opened; if a session already exists, WaitForSingleObject doesn't block anymore
- If I use CreateProcess with the two slashes, it works just as I need it.

I noticed that with at least one of the slashes, CreateProcess creates a new instance of winword.exe, else it opens a new document in the already existing process.

Also, with other applications (eg Notepad or even Excel), it works fine without the slashes.

Do you think that this is abnormal behaviour?
Why it needs the slashes? (i discovered this by pure luck, it isn't documented anywhere)



Enis Arif
-----------

"I am enough of an artist to draw freely upon my imagination. Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world." (Albert Einstein)
GeneralRe: CreateProcess strange behaviour?! Pin
Alois Kraus25-Mar-03 0:08
Alois Kraus25-Mar-03 0:08 
GeneralClick on static controls Pin
Cedric Moonen24-Mar-03 23:28
Cedric Moonen24-Mar-03 23:28 
GeneralRe: Click on static controls Pin
Rage25-Mar-03 0:09
professionalRage25-Mar-03 0:09 
GeneralRe: Click on static controls Pin
Roger Allen25-Mar-03 2:04
Roger Allen25-Mar-03 2:04 
Generalnewline character in CEdit Pin
r i s h a b h s24-Mar-03 23:20
r i s h a b h s24-Mar-03 23:20 
GeneralRe: newline character in CEdit Pin
Christian Graus24-Mar-03 23:54
protectorChristian Graus24-Mar-03 23:54 
GeneralRe: newline character in CEdit Pin
Rage25-Mar-03 0:07
professionalRage25-Mar-03 0:07 
Generalfile picker Pin
Willem B24-Mar-03 23:03
Willem B24-Mar-03 23:03 
GeneralRe: file picker Pin
Willem B24-Mar-03 23:24
Willem B24-Mar-03 23:24 
GeneralRe: file picker Pin
Cedric Moonen24-Mar-03 23:24
Cedric Moonen24-Mar-03 23:24 
GeneralRe: file picker Pin
Willem B24-Mar-03 23:26
Willem B24-Mar-03 23:26 
GeneralRe: file picker Pin
Cedric Moonen24-Mar-03 23:29
Cedric Moonen24-Mar-03 23:29 
GeneralCColorPropPage and Colors Pin
Arjan Schouten24-Mar-03 22:39
Arjan Schouten24-Mar-03 22:39 
GeneralCompiler Error C2825: cannot form a qualified name, NEEDS EXPLAINING Pin
eladho24-Mar-03 22:27
eladho24-Mar-03 22:27 
GeneralRe: Compiler Error C2825: cannot form a qualified name, NEEDS EXPLAINING Pin
João Paulo Figueira24-Mar-03 23:43
professionalJoão Paulo Figueira24-Mar-03 23:43 
GeneralRe: Compiler Error C2825: cannot form a qualified name, NEEDS EXPLAINING Pin
eladho24-Mar-03 23:49
eladho24-Mar-03 23:49 
QuestionHow many handles leaked can hold a win2k OS? Pin
Joan M24-Mar-03 22:02
professionalJoan M24-Mar-03 22:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.