VB程序怎样在运行时得到程序本身在磁盘中的位置?

解决方案 »

  1.   

    app.path  
    '得到当前程序所在路径
      

  2.   

    app.path程序下的目录:app.path+iif(right(app.path,1)="\","","\")+目录名
      

  3.   

    app.path
    ------------------------------------------------------------------
    个人专栏:http://www.csdn.net/develop/author/netauthor/lihonggen0/
    ------------------------------------------------------------------
      

  4.   

    roger_xiong(风过无痕) 的答案比较严谨
      

  5.   

    app.path
    或用GetCurrentDirectory 
    例子:
    Private Declare Function GetCurrentDirectory Lib "kernel32" Alias "GetCurrentDirectoryA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
    Private Sub Form_Paint()
        Dim sSave As String
        'create a buffer
        sSave = String(255, 0)
        'retrieve the current directory
        GetCurrentDirectory 255, sSave
        MsgBox sSave
    End Sub