|
Const MAX_FILENAME_LEN = 260
Private Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Long
Private Sub Form_Click()
Dim I As Integer, s2 As String
dim AutoCADPath as String
Const MyCADFile = "F:\temp2\try.CAD"
s2 = String(MAX_FILENAME_LEN, 32)
I = FindExecutable(MyCADFile, vbNullString, s2)
If I > 32 Then
AutoCADPath=Left$(s2, InStr(s2, Chr$(0)) - 1)
msgbox AutoCADPath '报告AutoCAD.exe程序的路径
shell AutoCADPath '运行AutoCAD.exe
Else
MsgBox "没找到AutoCAD程序!"
End If
End Sub
事先在自己程序目录下建立一个CAD文件,然后用上面的代码找运行这个CAD文件的程序(即AutoCAD.exe)所在的路径。 |
|