For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > January 2006 > findexecutabe and 4letter extension









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author findexecutabe and 4letter extension
Jim simons

2006-01-26, 6:56 pm


if iuse findexecutabl3 with a 4 letter extension iget a no extention
found error. however I can double click the filename with the four
letter extension and all works?

What am I doing wrong?


*** Sent via Developersdex http://www.developersdex.com ***
Michael Cole

2006-01-26, 6:56 pm

Jim simons wrote:
> if iuse findexecutabl3 with a 4 letter extension iget a no extention
> found error. however I can double click the filename with the four
> letter extension and all works?


OK, I'll bite - what the hell is "findexecutabe"? (Or even
"findexecutabl3" - I assume that that is the l33t version or the first?


--
Regards,

Michael Cole


Karl E. Peterson

2006-01-26, 6:56 pm

Michael Cole wrote:
> Jim simons wrote:
>
> OK, I'll bite - what the hell is "findexecutabe"?


http://msdn.microsoft.com/library/d...dexecutable.asp

> (Or even "findexecutabl3" - I assume that that is the l33t version or the
> first?


<g>
--
Working without a .NET?
http://classicvb.org/


Karl E. Peterson

2006-01-26, 6:56 pm

Jim simons wrote:
> if iuse findexecutabl3 with a 4 letter extension iget a no extention
> found error. however I can double click the filename with the four
> letter extension and all works?
>
> What am I doing wrong?


Well, without an actual example, all we can do is guess.

Were you aware that call requires a complete filename, not just an
extension?
--
Working without a .NET?
http://classicvb.org/


Karl E. Peterson

2006-01-26, 6:56 pm

Jim simons wrote:
> if iuse findexecutabl3 with a 4 letter extension iget a no extention
> found error. however I can double click the filename with the four
> letter extension and all works?
>
> What am I doing wrong?


Possibly nothing. I don't have any 4-letter extensions set up with
associations here. It's possible that's a bug? Here's another routine that
will show how to extract the association from the registry, if that's the
case:

Public Function FindExtAssociation(ByVal Extension As String) As String
Dim DocType As String
Dim OpenCommand As String
Const HKCR As Long = &H80000000

' Default value for .ext key is document type
DocType = FindExtDoctype(Extension)
If Len(DocType) Then
' Drill down to get command used to open this extension.
DocType = DocType & "\shell\open\command"
OpenCommand = RegGetStringValue(HKCR, DocType, "*")
' If this starts with quotes, extract up to 2nd quote.
' Ex: "C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe" "%1"
If InStr(OpenCommand, """") = 1 Then
OpenCommand = Mid$(OpenCommand, 2)
End If
If InStr(OpenCommand, """") > 1 Then
OpenCommand = Left$(OpenCommand, InStr(OpenCommand, """") - 1)
End If
End If

' Return results
FindExtAssociation = OpenCommand
End Function

Public Function FindExtDoctype(ByVal Extension As String) As String
Const HKCR As Long = &H80000000
' Make sure extension starts with a dot.
If InStr(Extension, ".") <> 1 Then Extension = "." & Extension
' Default value for .ext key is document type
FindExtDoctype = RegGetStringValue(HKCR, Extension, "*")
End Function

Note, you'll need your own RegGetStringValue function (but _everyone_ has
those, right? <g> ).
--
Working without a .NET?
http://classicvb.org/


David J Mark

2006-01-26, 6:56 pm


"Jim simons" <jasimons@finaocorp.com> wrote in message
news:eD1g0zsIGHA.1388@TK2MSFTNGP11.phx.gbl...
>
> if iuse findexecutabl3 with a 4 letter extension iget a no extention
> found error. however I can double click the filename with the four
> letter extension and all works?


So ShellExecute the document and be done with it. Why do you care where the
executable is?

>
> What am I doing wrong?
>
>
> *** Sent via Developersdex http://www.developersdex.com ***



Karl E. Peterson

2006-01-26, 9:55 pm

David J Mark wrote:
> "Jim simons" <jasimons@finaocorp.com> wrote...
>
> So ShellExecute the document and be done with it. Why do you care
> where the executable is?


One common reason would be to discover what version it is, particularly if
you're generating the intended document.
--
Working without a .NET?
http://classicvb.org/


Jim

2006-01-27, 6:56 pm


I thought I might have to walk to the registry tree I was trying to
avoid it. Thanks for the snippet. To the other questions. I need to
launch the application and wait for it to finish and then continue on
with the rest of the code.

FindExecutable works fine with three letter extensions and 4 letter than
are built it (.html) I created an extension .abcd and associated it with
the application I wanted it to load and it always failed with error 31
(no association) i did the same test with extension .abc and all works
fine. I thought I may have missed a resitry setting somewhere when I
used my association code.

Thanks for the quick replys.


*** Sent via Developersdex http://www.developersdex.com ***
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com