难道是VB盗版或是VB本身的漏洞引起的原因????

sear 2004-07-15 05:29:44
我在VB下面我有一个方法是执行一个批处理文件的 用了API函数
'获取MAC地址的组件方法

Public Function GetMacAddress()
ShellExecute 0, "open", "D:\GetMacAdd\DosGetMac.Bat", "-s", "", 0
End Function

当编译后生成Dll文件 注册后 在ASP页面调用的时候却什么错误也没有 可是却没有执行到DosGetMac.Bat文件

DosGetMac.Bat文件的内容是
dir > D:\GetMacAddr\Mac.Txt 意思是将dir显示出来的信息重定向到Mac.Txt文件里

可是执行后Mac.Txt文件里什么也没有 但是当我直接运行DosGetMac.Bat时内容是被写入到Mac.Txt文件里的,我想不该是DosGetMac.Bat文件的问题,所以请大家帮忙看看ShellExecute 0, "open", "D:\GetMacAdd\DosGetMac.Bat", "-s", "", 0
是不是错了 或该怎么办??

另外就是让我郁闷了好几天也没有解决的办法
我不用ShellExecute来运行文件
用Shell "D:\GetMacAddr\DosGetMac.Bat", vbHide
可是却报告说是Invalid procedure call or argument 的错误,,

Shell "D:\GetMacAddr\DosGetMac.Bat", vbHide 很多人都是调试通过的 我就是不通过老实这个错误,包括运行其他的文件也是这样的 难道他还要认人不成了??
我的开发环境是windows 2003 + VB6.0

我是实在没有办法了 ,,请大家帮帮忙吧~~~~ 难道这个VB本身的问题 还是是VB是用倒板的原因呀
...全文
192 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
dongge2000 2004-07-15
  • 打赏
  • 举报
回复
UP
ryuginka 2004-07-15
  • 打赏
  • 举报
回复
up
Linus2000 2004-07-15
  • 打赏
  • 举报
回复
如果你想获取本机MAC地址可以这样做
Set NetAdapterSet = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_NetworkAdapter")

For Each NetAdapter In NetAdapterSet
txt = NetAdapter.MACAddress
Next
jam021 2004-07-15
  • 打赏
  • 举报
回复
试试shell "cmd /c D:\GetMacAdd\DosGetMac.Bat"

northwolves 2004-07-15
  • 打赏
  • 举报
回复
try:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Command1_Click()
Open "D:\GetMacAdd\DosGetMac.Bat" For Output As 1
Print #1, "dir > D:\GetMacAddr\Mac.Txt"
Close 1
Shell "D:\GetMacAdd\DosGetMac.Bat"
'h = Shell("COMMAND.COM /C ", 0)
ShellExecute hwnd, "open", "D:\GetMacAddr\Mac.Txt", "notepad.exe", vbNullString, 5
End Sub
rainstormmaster 2004-07-15
  • 打赏
  • 举报
回复
//Shell "D:\GetMacAddr\DosGetMac.Bat", vbHide 很多人都是调试通过的 我就是不通过老实这个错误,包括运行其他的文件也是这样的 难道他还要认人不成了??

没用过2003,估计是操作系统的问题
wxrwan 2004-07-15
  • 打赏
  • 举报
回复
gz

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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