Public Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long利用这个API函数将Program Files这样的路径转换为短路径。然后再运行程序
Public Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As LongPublic Function Gs(LongName As String) As String Dim ShortName As String * 256 GetShortPathName LongName, ShortName, 256 Gs = ShortName End Function
最好是用APP,或是直接调用就可以了 On Error Resume Next
Shell "calc.exe"
这样应该是可以了,调用计算器
Shell ("C:\programfiles\RNAstructure.exe /fold -s " & fn11 & " -c " & fn22)
"fold -s " & fn11 & " -c " & fn22"是 RNAstructure.exe 的命令,不用理它。
我的VB差,帮我写一下代码,急用。谢谢!!
tj123写的代码放在子文件夹里没问题,放在某个盘下就......
Shell ("D:\Program Files\RNAstructure 4.11\RNAstructure /fold -s " & fn11 & " -c " & fn22)
十分奇怪的是:我把自己的程序放在桌面上,RNAstructure能被调用但却不执行命令也不自动退出,(任务管理器中有进程出现,但不占用CPU),
但是如果我把自己的程序放在“D:\Program Files\RNAstructure 4.11”之下却没有任何问题,RNAstructure 调用执行任务后自动退出。
另外shell 前面加一个call 吧 这样不影响程序 不过合理一些
我的API不熟,请帮我把代码写完好吗?谢谢!!
Dim ShortName As String * 256
GetShortPathName LongName, ShortName, 256
Gs = ShortName
End Function