Click here to Skip to main content
15,910,872 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to restore minimized window? Pin
vgrigor30-Sep-03 3:28
vgrigor30-Sep-03 3:28 
AnswerRe: How to restore minimized window? Pin
David Crow30-Sep-03 3:37
David Crow30-Sep-03 3:37 
GeneralRe: How to restore minimized window? Pin
vgrigor30-Sep-03 3:48
vgrigor30-Sep-03 3:48 
GeneralCSocket - CSocketFile - CArchive Problem Pin
Brian Cox30-Sep-03 3:04
Brian Cox30-Sep-03 3:04 
GeneralRe: CSocket - CSocketFile - CArchive Problem Pin
DougW4830-Sep-03 7:01
DougW4830-Sep-03 7:01 
GeneralRe: CSocket - CSocketFile - CArchive Problem Pin
Brian Cox30-Sep-03 7:09
Brian Cox30-Sep-03 7:09 
GeneralSpy++ Pin
hph30-Sep-03 1:59
hph30-Sep-03 1:59 
GeneralMFC ShellExecuteEx structure Pin
Uke30-Sep-03 1:53
Uke30-Sep-03 1:53 
I'm still new to c++ so please bare with me.

I'm using the ShellExecuteEx in MFC to open a Acrobat .pdf document.
When Acrobat is closed after the document has opened or the process is closed I want to remove the file from the Directory.

my code looks like this.

<br />
//***************************************************************************<br />
char pathBuffer[MAX_PATH];<br />
char szCurrDir[MAX_PATH];<br />
<br />
GetCurrentDirectory(MAX_PATH,szCurrDir);<br />
GetTempFileName (szCurrDir, "", 0, pathBuffer);<br />
CString stmpfile = pathBuffer;<br />
<br />
SHELLEXECUTEINFO si;<br />
	memset(&si, 0, sizeof(si));<br />
	si.cbSize = sizeof(si);<br />
	si.hwnd = this->m_hWnd;<br />
	si.lpVerb = "open";<br />
	si.lpFile = pathBuffer;<br />
	si.nShow = SW_NORMAL;<br />
	si.hInstApp = NULL;	<br />
	si.fMask = SEE_MASK_NOCLOSEPROCESS;<br />
	int res = ShellExecuteEx(&si);<br />
	if (res==1)<br />
		WaitForSingleObject(si.hProcess,INFINITE);<br />
   <br />
<br />
        CloseHandle(si.hProcess);<br />
<br />
<br />
	//Remove the temp File from Directory<br />
	remove(stmpfile);<br />
//***************************************************************************<br />




When there is no instance of Acrobat running it works fine. But as soon as Acrobat is already running or an instance of the Acrobat exe still in the process tray it doesn’t seem to open the .pdf document.

I cannot use the ShellExecute structure for the simple reason that I need to know when Acrobat is closed so that I can remove that file from the directory.

The ShellExecute will open the Acrobat document regardless of whether there an instance is of Acrobat running.

//ShellExecute(this->m_hWnd,"open",pathBuffer, NULL, NULL, SW_SHOWNORMAL);

Any help would really be appreciated.
GeneralRe: MFC ShellExecuteEx structure Pin
David Crow30-Sep-03 2:28
David Crow30-Sep-03 2:28 
GeneralRe: MFC ShellExecuteEx structure Pin
Uke30-Sep-03 2:47
Uke30-Sep-03 2:47 
GeneralRe: MFC ShellExecuteEx structure Pin
Uke30-Sep-03 2:55
Uke30-Sep-03 2:55 
GeneralRe: MFC ShellExecuteEx structure Pin
David Crow30-Sep-03 2:56
David Crow30-Sep-03 2:56 
GeneralDebug Assertion Failure Pin
Saurabh_Delhi30-Sep-03 1:50
Saurabh_Delhi30-Sep-03 1:50 
GeneralRe: Debug Assertion Failure Pin
jhwurmbach30-Sep-03 1:55
jhwurmbach30-Sep-03 1:55 
GeneralRe: Debug Assertion Failure Pin
Saurabh_Delhi30-Sep-03 2:20
Saurabh_Delhi30-Sep-03 2:20 
GeneralRe: Debug Assertion Failure Pin
jhwurmbach30-Sep-03 2:31
jhwurmbach30-Sep-03 2:31 
GeneralRe: Debug Assertion Failure Pin
David Crow30-Sep-03 2:43
David Crow30-Sep-03 2:43 
GeneralRe: Debug Assertion Failure Pin
David Crow30-Sep-03 2:40
David Crow30-Sep-03 2:40 
GeneralRe: Debug Assertion Failure Pin
Saurabh_Delhi30-Sep-03 3:06
Saurabh_Delhi30-Sep-03 3:06 
GeneralRe: Debug Assertion Failure Pin
David Crow30-Sep-03 3:35
David Crow30-Sep-03 3:35 
GeneralCode to read thru Pin
bhangie30-Sep-03 0:39
bhangie30-Sep-03 0:39 
GeneralRe: Code to read thru Pin
Maximilien30-Sep-03 0:58
Maximilien30-Sep-03 0:58 
GeneralRe: Code to read thru Pin
David Crow30-Sep-03 2:44
David Crow30-Sep-03 2:44 
QuestionEditbox multiline problem??? Pin
xxhimanshu30-Sep-03 0:32
xxhimanshu30-Sep-03 0:32 
AnswerRe: Editbox multiline problem??? Pin
David Crow30-Sep-03 2:45
David Crow30-Sep-03 2:45 

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.