用COMMAND变量返回命令行参数在调试时候可以在“工程->属性-.>生成->命令行参数"里面设置

解决方案 »

  1.   

    这需要建立文件关联,也就是某个后缀的文件用哪种.exe工具将此后缀的文件打开 
    下面是一段代码,可以用来做到文件关联. Option Explicit Function FileExists(ByVal FileName As String) As Integer 
    Dim Temp$ 'Set Default 
    FileExists = True 'Set up error handler 
    On Error Resume Next 'Attempt to grab date and time 
    Temp$ = FileDateTime(FileName) 'Process errors 
    Select Case Err 
    Case 53, 76, 68 'File Does Not Exist 
    FileExists = False 
    Err = 0 
    Case Else 
    If Err <> 0 Then 
    MsgBox "Error Number: " & Err & Chr$(10) & Chr$(13) & " " & Erroor, MB_OK, "Error" 
    End 
    End If 
    End Select 
    End Function Function AddPathToFile(ByVal sPathIn As String, ByVal sFileNameIn As String) As String 
    '******************************************************************* 

    ' PURPOSE: Takes a path (including Drive letter and any subdirs) and 
    ' concatenates the file name to path. Path may be empty, path 
    ' may or may not have an ending backslash '\'. No validation 
    ' or existance is check on path or file. 

    ' INPUTS: sPathIn - Path to use 
    ' sFileNameIn - Filename to use 



    ' OUTPUTS: N/A 

    ' RETURNS: Path concatenated to File. 

    '******************************************************************* 
    Dim sPath As String 
    Dim sFileName As String 
    'Remove any leading or trailing spaces 
    sPath = Trim$(sPathIn) 
    sFileName = Trim$(sFileNameIn) If sPath = "" Then 
    AddPathToFile = sFileName 
    Else 
    If Right$(sPath, 1) = "\" Then 
    AddPathToFile = sPath & sFileName 
    Else 
    AddPathToFile = sPath & "\" & sFileName 
    End If 
    End If 
    End If End Function 
    Function ExtractFileName(sFileName As Variant) As String 
    '******************************************************************* 

    ' PURPOSE: This returns just a file name from a full/partial path. 

    ' INPUTS: sFileName - String Data to remove path from. 

    ' OUTPUTS: N/A 

    ' RETURNS: This function returns all the characters from right to the 
    ' first \. Does NOT check validity of the filename.... 

    '******************************************************************* 
    Dim nIdx As Integer 
    For nIdx = Len(sFileName) To 1 Step -1 
    If Mid$(sFileName, nIdx, 1) = "\" Then 
    ExtractFileName = Mid$(sFileName, nIdx + 1) 
    Exit Function 
    End If 
    Next nIdx ExtractFileName = sFileName End Function Function ExtractPath(sFileName) As String 
    '******************************************************************* 

    ' PURPOSE: This returns just a path name from a full/partial path. 

    ' INPUTS: sFileName - String Data to remove file from. 

    ' OUTPUTS: N/A 

    ' RETURNS: This function returns all the characters from left to the last 
    ' first \. Does NOT check validity of the filename/Path.... 
    '******************************************************************* 
    Dim nIdx As Integer For nIdx = Len(sFileName) To 1 Step -1 
    If Mid$(sFileName, nIdx, 1) = "\" Then 
    ExtractPath = Mid$(sFileName, 1, nIdx) 
    Exit Function 
    End If 
    Next nIdx ExtractPath = sFileName End Function 
      

  2.   

    txt文件在注册表中的的注册方式
    [HKEY_CLASSES_ROOT\txtfile\shell\open\command]
    @="C:\\WINDOWS\\NOTEPAD.EXE %1"
    将它的注册中的C:\\WINDOWS\\NOTEPAD.EXE 改成你文件,并且在自己程序中传参数
      

  3.   

    '工程文件开始
    '
    '
    Type=Exe
    Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\SYSTEM\stdole2.tlb#OLE Automation
    Module=Module1; Module1.bas
    Startup="Sub Main"
    HelpFile=""
    Title="工程1"
    ExeName32="工程1.exe"
    Command32="hello,baby"
    Name="工程1"
    HelpContextID="0"
    CompatibleMode="0"
    MajorVer=1
    MinorVer=0
    RevisionVer=0
    AutoIncrementVer=0
    ServerSupportFiles=0
    VersionCompanyName="m$ corp"
    CompilationType=0
    OptimizationType=0
    FavorPentiumPro(tm)=0
    CodeViewDebugInfo=0
    NoAliasing=0
    BoundsCheck=0
    OverflowCheck=0
    FlPointCheck=0
    FDIVCheck=0
    UnroundedFP=0
    StartMode=0
    Unattended=0
    Retained=0
    ThreadPerObject=0
    MaxNumberOfThreads=1
    '工程文件结束'模块文件开始
    Attribute VB_Name = "Module1"
    Option Explicit
    Dim strCMDLINE As StringSub Main()
      strCMDLINE = Trim(Command)
      If Len(strCMDLINE) = 0 Then
        newfile
      Else
        openfile
      End If
    End SubSub newfile()
      '没有命令行参数时候处理本例程
      MsgBox "empty"
    End SubSub openfile()
      '有命令行参数时候处理本例程
      MsgBox strCMDLINE
    End Sub
    '模块文件结束
    具体怎么关联
    上面帖子有
    也可以在 资源管理器->查看->文件夹选向->文件类型 里面修改Option Explicit
    Dim strCMDLINE As StringSub main()
      strCMDLINE = Trim(Command)
      If Len(strCMDLINE) = 0 Then
        newfile
      Else
        openfile
      End If
    End SubSub newfile()
      '没有命令行参数时候处理本例程
      MsgBox "empty"
    End SubSub openfile()
      '有命令行参数时候处理本例程
      MsgBox strCMDLINE
    End Sub
      

  4.   

    文件关联:
    http://www.csdn.net/expert/topic/524/524025.xml?temp=.8654749
      

  5.   

    好象有被超长切掉了一些
    CSDN规定最长多少行的?
      

  6.   

    FROM_LOAD 时,
    判断COMMAND的值,COMMAND就是文件路径。