| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1579 人关注过本帖
标题:如何编一个可执行程序实现一个带参数的DOS命命?
只看楼主 加入收藏
doyouwant
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-9-29
收藏
 问题点数:0 回复次数:4 
如何编一个可执行程序实现一个带参数的DOS命命?
如何编一个可执行程序实现一个带参数的DOS命命? 如 del.exe f.dt  -r -x
搜索更多相关主题的帖子: DOS 执行程序 参数 
2008-09-30 11:44
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
收藏
得分:0 
6月4日
关于API GetCommandLine的使用
算留做参考资料吧,免得有人继续不会用还查不到正确的资料。
 
Public Declare Function GetCommandLine Lib "kernel32" Alias "GetCommandLineA" () As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As String, ByVal Source As Long, ByVal Length As Long)

 
Function fGetCommandLine() As String
    Dim lRet As Long, sCmd As String
    lRet = GetCommandLine
    If lRet > 0 Then
            sCmd = String(256, 32)
            CopyMemory sCmd, lRet, Len(sCmd)
            sCmd = Mid(sCmd, 1, InStr(1, sCmd, Chr(0)) - 1)
    End If
    fGetCommandLine = sCmd
   
    ' 关于API GetCommandLine的使用说明
    ' MSDN:
    ' The return value is a pointer to the command-line string for the current process.
    ' 返回字符串指针(指向当前命令行缓冲区的一个指针),并非字符串,API Viewer的声明是错误的。
    ' References:
    ' http://topic.
   
End Function
 
 
MSDN98(for VC++6, 1033):
GetCommandLine
The GetCommandLine function returns a pointer to the command-line string for the current process.

LPTSTR GetCommandLine(VOID)
 Parameters
This function has no parameters.

Return Values
The return value is a pointer to the command-line string for the current process.

Remarks
ANSI console processes written in C can use the argc and argv arguments of the main function to access the command-line arguments. ANSI GUI applications can use the lpCmdLine parameter of the WinMain function to access the command-line string, excluding the program name. The reason that main and WinMain cannot return Unicode strings is that argc, argv, and lpCmdLine use the LPSTR data type for parameters, not the LPTSTR data type. The GetCommandLine function can be used to access Unicode strings, because it uses the LPTSTR data type.

QuickInfo
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in winbase.h.
  Import Library: Use kernel32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows and Windows NT.

See Also
Processes and Threads Overview, Process and Thread Functions, CreateProcess, WinMain

 
http://multiple001.spaces.
2008-09-30 12:48
haigecnpeng
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:2
帖 子:261
专家分:510
注 册:2008-10-6
收藏
得分:0 
请教:
用ShellExecute函数是不是不支持参数的呢?

都说到了.net年代,VB与C#都是一样的!
但为什么招聘的都是C#呢?
2008-10-10 23:56
三断笛
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:31
帖 子:1621
专家分:1617
注 册:2007-5-24
收藏
得分:0 
SHELL和SHELLEXECUTE都支持
如:
SHELL "cmd /c del.exe f.dt  -r -x"
SHELLEXECUTE &0,"OPEN","cmd","/c del f.dt -r -x","",0
2008-10-11 08:50
沙海绿洲
Rank: 1
等 级:新手上路
帖 子:22
专家分:3
注 册:2007-12-6
收藏
得分:0 
还真的有啊,不过英文不懂.
2008-10-11 23:34
快速回复:如何编一个可执行程序实现一个带参数的DOS命命?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.067277 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved