|
皆様、返信ありがとうございます。 とても参考になりました。
教えて頂いたurlやサンプルプログラムにすこし手を加えたらできました。 Exeのパスが取得できましたので・・・・・・。
ソースをupしますので、何かご指摘の点がありましたら宜しくお願いします。
Imports System Imports System.Runtime.InteropServices Imports System.Text
Public Class test
<DllImport("Shlwapi.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _ Private Shared Function AssocQueryString(ByVal flags As AssocF, ByVal str As AssocStr, ByVal pszAssoc As String, _ ByVal pszExtra As String, ByVal pszOut As StringBuilder, ByRef pcchOut As System.UInt32) As Integer
End Function
Public Sub main()
Dim strExtra As String = Nothing Dim intret As Integer Dim intpcchout As System.UInt32 = 0 Dim pszOut_L As New StringBuilder Dim doc As String
Try
intret = AssocQueryString(test.AssocF.Verify, test.AssocStr.Executable, ".txt", strExtra, Nothing, intpcchout)
pszOut_L = New StringBuilder(CInt(intpcchout))
intret = AssocQueryString(test.AssocF.Verify, test.AssocStr.Executable, ".txt", strExtra, pszOut_L, intpcchout)
doc = pszOut_L.ToString
Catch ex As Exception MsgBox(ex.Message) End Try
End Sub
<Flags()> _ Private Enum AssocF As Integer Init_NoRemapCLSID = 1 Init_ByExeName = 2 Open_ByExeName = 2 Init_DefaultToStar = 4 Init_DefaultToFolder = 8 NoUserSettings = &H10 NoTruncate = &H20 Verify = &H40 RemapRunDll = &H80 NoFixUps = &H100 IgnoreBaseClass = &H200 End Enum
Private Enum AssocStr As Integer Command = 1 Executable FriendlyDocName FriendlyAppName NoOpen ShellNewValue DDECommand DDEIfExec DDEApplication DDETopic End Enum
End Class
|