对.EXE文件传值的问题

wangdequan1024 2005-07-04 02:23:55
如何向一个由VB.NET生成的EXE文件传递两个值,又该如何接收,请指教,急用。
比如向master.exe 传递 UserId,UserName两个值
...全文
292 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
真相重于对错 2005-07-05
  • 打赏
  • 举报
回复
楼主还要传回
miaojx 2005-07-05
  • 打赏
  • 举报
回复
Public Sub Main(ByVal CmdArgs() As String)
Dim decLdate, decTbsdy As Decimal
If CmdArgs.Length = 0 Then
If getPbcLdate() <> 0 Then
decLdate = getPbcLdate()
End If
If getPbcTbsdy() <> 0 Then
decTbsdy = getPbcTbsdy()
End If
Else
decLdate = CmdArgs.GetValue(0)
decTbsdy = CmdArgs.GetValue(1)
End If
Catch ex As Exception
Finally
End Try
End Sub
在調用処
Shell("..\你的exe " & decLdate1 & " " & decTbsdy1, AppWinStyle.NormalFocus, False)
wangdequan1024 2005-07-05
  • 打赏
  • 举报
回复
结贴了,多谢大家的帮忙,
用Environment.GetCommandLineArgs()
就可以了。
xjtandqt 2005-07-04
  • 打赏
  • 举报
回复
我的erp系统登入子系统也是传userID,userName 的
我是这样实现的:

'订单模块
Module OrderModule
'定义sub main,项目启动,选择sub main启动
'aa()为参数数组,aa(0)保存userID和userName
Public Sub main(ByVal aa() As String)

If aa.GetUpperBound(0) < 0 Then

UserID = ""
UserName = ""
'参数为空,弹出登入窗体,重新登入
Else
'对aa(0),按"@"进行分割,SplitToArr函数自己再写,我写的不好.
dim lsArr()
SplitToArr(lsString, "@", lsArr)
UserID=lsArr(0)
UserName=lsArr(1)
'直接进入订单子系统
end if
End Sub
end Module

传参数事件代码:

'AppPath & "\ordermanage.exe "为可执行文件,lsString 就是参数

lsString=userID & "@" & UserName
Shell(AppPath & "\ordermanage.exe " & lsString, AppWinStyle.NormalFocus)
upshania 2005-07-04
  • 打赏
  • 举报
回复
我认为这种内存管道方式不太实用呢。。。因为我觉得可能这个EXE文件你是准备用在客户端的

你可以通过一个IE的ACTIVEX控件 通过信任证书 安装到客户端OCX 然后通过这个OCX操作注册表。。写入一些串值。。。。然后通过EXE文件定时获取注册表信息。。。然做这个操作

客户端的工具我觉得用VB.NET生成的也不行。。。因为客户端不会都有。NET环境。。。应该用DELPHI c++ 等来开发
真相重于对错 2005-07-04
  • 打赏
  • 举报
回复
共享内存文件
ms-help://MS.MSDNQTR.2003FEB.2052/fileio/base/creating_named_shared_memory.htm
真相重于对错 2005-07-04
  • 打赏
  • 举报
回复
如果在启动时获得数据,楼上的这些都可,
如果两个exe,运行时互相交换数据,微软给提供的标准方式使用命名管道,和共享内存,或者使用remoting(感觉在单机下不太合适),
关于命名管道,和共享内存需要调用winapi,具体操作看《windows 高级编程》。我vb不懂,不好给你写
koomis 2005-07-04
  • 打赏
  • 举报
回复
public shared function Main(byval args() as string)

end sub
然后处理ARGS就可以得到传入的值了
JzeroBiao 2005-07-04
  • 打赏
  • 举报
回复
顶..
oo渣渣oo 2005-07-04
  • 打赏
  • 举报
回复
Command()可以接收外部传入的参数.

例: test.exe /A:123

那么Command()收到的就是"/A:123"

不知道你要表达的是不是这个意思?
3tzjq 2005-07-04
  • 打赏
  • 举报
回复
没太看懂!不可以在Main中作文章处理?

public shared function Main(byval args() as string)
{
if (args.Length = 2)'args(0)为UsreID,args(1)为UserName
application.run(new master(args(0),args(1))//传入参数
end if
end sub


master 类中:
public sub new(UsreID as string,UserName as string)
.........
MessageBox.Show(UsreID + vblf + UserName)
end sub

test:
Process.Start("..\master.exe","wangdequan1024","紫夜")
wangdequan1024 2005-07-04
  • 打赏
  • 举报
回复
TO: hdt(接分接出个星星)
说得明白些~
真相重于对错 2005-07-04
  • 打赏
  • 举报
回复
管道,共享内存文件
sz_lgp 2005-07-04
  • 打赏
  • 举报
回复
可以在.exe中按排读取一个.txt文件,而.txt文件中只有UserID,UserName,且可以更改保存UserID,UserName到.txt中。
wangdequan1024 2005-07-04
  • 打赏
  • 举报
回复
大家帮帮忙,我会尽快结贴~

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧