app crash on ShellExecute()

Post Reply
User avatar
reinaldocrespo
Posts: 918
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

app crash on ShellExecute()

Post by reinaldocrespo »

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


//----------------------------------------------------------------------------
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
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: app crash on ShellExecute()

Post by Otto »

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

********************************************************************
User avatar
reinaldocrespo
Posts: 918
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: app crash on ShellExecute()

Post by reinaldocrespo »

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
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Re: app crash on ShellExecute()

Post by Richard Chidiak »

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

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
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: app crash on ShellExecute()

Post by Enrico Maria Giordano »

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

WinExec( "START " + cDocument )
EMG
User avatar
reinaldocrespo
Posts: 918
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: app crash on ShellExecute()

Post by reinaldocrespo »

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
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Re: app crash on ShellExecute()

Post by Richard Chidiak »

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
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: app crash on ShellExecute()

Post by Enrico Maria Giordano »

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
reinaldocrespo
Posts: 918
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: app crash on ShellExecute()

Post by reinaldocrespo »

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
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

Re: app crash on ShellExecute()

Post by fraxzi »

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
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: app crash on ShellExecute()

Post by Otto »

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

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

********************************************************************
Post Reply