app crash on ShellExecute()

app crash on ShellExecute()

Postby reinaldocrespo » Thu Jan 05, 2012 7:21 pm

Hi.

I'm getting an occasional gpf exception:

Problem signature:
Problem Event Name: APPCRASH
Application Name: PathLabs10.Exe
Application Version: 0.0.0.0
Application Timestamp: 00000000
Fault Module Name: StackHash_ff05
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 00000000
Exception Code: c000001d
Exception Offset: 04ae8155
OS Version: 6.1.7600.2.0.0.256.1
Locale ID: 1033
Additional Information 1: ff05
Additional Information 2: ff05f37046acef5185ebb7cab4cbfa4d
Additional Information 3: de26
Additional Information 4: de26bf487b3c10560592a1bede0ad9ce


It happens when executing the command ShellExecute() from the code below:
Code: Select all  Expand view  RUN


//----------------------------------------------------------------------------
METHOD OpenFile() Class Referrings
   LOCAL cFile := temp_name( ALLTRIM( ::oDocsTbl:ImageType ) )
   LOCAL oWnd, lCreated

   //MemoWrit( cFile, ::oDocsTbl:Image )
   lCreated := (::oDocsTbl:cAlias)->( BLOBExport( ::oDocsTbl:FieldPos("Image"), cfile , BLOB_EXPORT_OVERWRITE ) )

   IF file( cFile ) .AND. lCreated

      DEFINE WINDOW oWnd FROM 0,0 TO -1, -1
      ACTIVATE WINDOW oWnd ON INIT ;
         ShellExecute( 0, "Open", cfile,,,1 )

      oWnd:End()

   ENDIF
     
RETURN NIL
 


When the gpf occurs it does before executing oWnd:End() but cfile is opened and displayed just fine. Most times cfile is a pdf. Any ideas where to look?


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: app crash on ShellExecute()

Postby Otto » Thu Jan 05, 2012 7:48 pm

I had many problems with ShellExecute. I do now use Winexec with no problems.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm

Re: app crash on ShellExecute()

Postby reinaldocrespo » Thu Jan 05, 2012 7:56 pm

Thank you very much.

Ok. I see. The problem I have is that I'm trying to open a document. It might be a .docx, or a .xls, or a .pdf, etc... WinExec() executes an app but it does not seem to open a document with it's associated app (if there is one). Right?


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: app crash on ShellExecute()

Postby Richard Chidiak » Fri Jan 06, 2012 9:29 am

Reinaldo ,

For opening documents (pdf ..) or executing internet tasks i use this piece of code instead of shellexecute

works Ok for me,

Hth

Richard

Code: Select all  Expand view  RUN

Function WebBrowser(cUrl,lvisible)
local oIE := CREATEOBJECT( "InternetExplorer.Application" )
IF LVISIBLE == nil
   lVisible := .t.
ENDIF
WITH OBJECT oIE
   :Visible   := LVISIBLE  
   :ToolBar   := .F.
   :StatusBar := .F.
   :MenuBar   := .F.
   :Invoke( "Navigate", cUrl )
END WITH
RETURN NIL
 
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: app crash on ShellExecute()

Postby Enrico Maria Giordano » Fri Jan 06, 2012 11:38 am

reinaldocrespo wrote:The problem I have is that I'm trying to open a document. It might be a .docx, or a .xls, or a .pdf, etc... WinExec() executes an app but it does not seem to open a document with it's associated app (if there is one). Right?


Try

Code: Select all  Expand view  RUN
WinExec( "START " + cDocument )


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: app crash on ShellExecute()

Postby reinaldocrespo » Fri Jan 06, 2012 4:30 pm

Enrico;

I really like your solution for its simplicity. However, for some reason, it doesn't always work. I would think that perhaps the file association isn't set but that is not the case. If I type the filename manually on the command prompt the associated app will open the file -while from source code, sometimes nothing happens.

Richard's solution seems to work but it opens ie, which I'd like to avoid.


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: app crash on ShellExecute()

Postby Richard Chidiak » Fri Jan 06, 2012 4:36 pm

Reinaldo

Opening ie is default behaviour that you can change

WebBrowser(cUrl,.f.) // does not show ie , i use it this way for all php i execute on my server, it goes silent

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: app crash on ShellExecute()

Postby Enrico Maria Giordano » Fri Jan 06, 2012 4:52 pm

reinaldocrespo wrote:Enrico;

I really like your solution for its simplicity. However, for some reason, it doesn't always work. I would think that perhaps the file association isn't set but that is not the case. If I type the filename manually on the command prompt the associated app will open the file -while from source code, sometimes nothing happens.

Richard's solution seems to work but it opens ie, which I'd like to avoid.


Reinaldo.


Please note that if cDocument contains spaces you have to enclose it in quotes (just like you have to do on the console).

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: app crash on ShellExecute()

Postby reinaldocrespo » Fri Jan 06, 2012 6:56 pm

Enrico;

There are no spaces. I don't use the quotes when I test from the console either. And yes... it does work well from the console:

start c:\users\admini~1\locals~1\temp\4872091.pdf


But from code, nothing happens:

WinExec( "START " + ALLTRIM( cFile ) )


where cfile contains: C:\Users\ADMINI~1\LOCALS~1\Temp\4872091.pdf

I appreciate your input and suggestions. I will continue testing with other files to see if I can debug this thing.



Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: app crash on ShellExecute()

Postby fraxzi » Sat Jan 07, 2012 12:42 pm

Dear Reinaldo,

Have you tried

WinExec( 'START "' + ALLTRIM( cFile )+'"' ) ?
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: app crash on ShellExecute()

Postby Otto » Fri Jan 31, 2020 3:58 pm

Hello,
Thank you for this code.
I use it now to open my help system on the internet.
I inserted the line oIE := NIL . Otherwise, the code calling twice errored out.
Best regards
Otto

Code: Select all  Expand view  RUN
Function WebBrowser(cUrl,lvisible)
    local oIE := CREATEOBJECT( "InternetExplorer.Application" )
    IF LVISIBLE == nil
       lVisible := .t.
    ENDIF
    WITH OBJECT oIE
       :Visible   := LVISIBLE  
       :ToolBar   := .F.
       :StatusBar := .F.
       :MenuBar   := .F.
       :Invoke( "Navigate", cUrl )
    END WITH
   
   
    oIE := NIL
    RETURN NIL
     
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 65 guests