Board logo

标题: [其他] 批处理调用dll函数的工具_call.exe(2009-06-01) [打印本页]

作者: Batcher    时间: 2009-4-28 15:12     标题: 批处理调用dll函数的工具_call.exe(2009-06-01)

http://www.dostips.com/forum/viewtopic.php?t=504

Hi all,

I have created handy and portable command line utility that is
able to call dllexported functions:
http://www.2shared.com/file/5485995/4b969d2c/_call.html


弹出一个包含 yes 和 no 按钮的窗口
  1. @echo off
  2. _call user32.dll MessageBoxA -d 0 -s "Yes or No?" -s "Question" -d 36
  3. rem 36 = MB_ICONQUESTION+MB_YESNO
  4. if %errorlevel% == 6 (goto :yes) else (goto :no)
  5. :yes
  6. echo Yes!
  7. pause
  8. exit
  9. :no
  10. echo No!
  11. pause
  12. exit
复制代码
计算两个时间的差值
  1. @echo off
  2. _call kernel32.dll GetTickCount
  3. set /a start=%errorlevel%
  4. set /p name=请输入你的名字:
  5. _call kernel32.dll GetTickCount
  6. set /a end=%errorlevel%
  7. set /a diff=%end%-%start%
  8. echo 你好 %name%,你花了 %diff% 秒钟来输入你的名字。
  9. pause
  10. exit
复制代码
更换桌面壁纸
  1. @echo off
  2. set /p img=请输入需要设置为壁纸的bmp格式图片路径:
  3. _call user32.dll SystemParametersInfoA -d 20 -d 0 -s "%img%" -d 3
  4. pause
  5. exit
复制代码
获取字符串长度
  1. @echo off
  2. set /p str=Type something :
  3. _call msvcrt.dll strlen -s "%str%"
  4. echo String length: %errorlevel% chars
  5. pause
  6. exit
复制代码
===============================以下为原作者2009-04-30更新===============================

Hello again, I'm back with a new release!

New features and fixes:
- It has now support for string pointers (dll out, in/out)
- Support for hex decimals
- Return value can be used as handle to anyting!
-> Three new definition selectors: -s' (str in/out), -s# (str in) and -x (hex decimal)
- Better help screen

Still missing:
- Support for structures (e.g. COORD {X,Y})
- Decimal pointers (app may crash if you try)


可执行文件、实例、更新日志下载

原作者提供的下载地址:http://drop.io/cmd_call
本地下载:http://bcn.bathome.net/s/tool/index.html?key=_call
作者: pusofalse    时间: 2009-4-28 17:18

看了下貌似只有-d 和-s两种参数类型,涉及到指针的API可能就不能调用了吧~

弹出光驱:
  1. _call ntmsapi.dll EjectDiskFromSADriveA -s "" -s "" -s "\\.\CdRom0" -d "" -s "" -s "" -d 4
复制代码

[ 本帖最后由 pusofalse 于 2009-4-28 17:28 编辑 ]
作者: Batcher    时间: 2009-4-28 19:15     标题: 回复 2楼 的帖子

你可以到dostips论坛问问原作者,或者我帮你问也行。
^_^
作者: 小勇12    时间: 2009-4-28 22:32

我顶 学习了 ,谢谢楼主
作者: Batcher    时间: 2009-4-29 00:35

Our users have posted a total of 1131 articles
We have 395 registered users
The newest registered user is pusofalse


看到你注册了,你自己问吧,呵呵。
作者: sniperhgy    时间: 2009-4-30 11:15

請問,rundll32與這個相比,有什麽不同呢?
作者: tireless    时间: 2009-5-16 14:54

calldll.zip - 2.40 KB - compiled 2006-03-08 - Calls a function in a dll file. The function must use the stdcall calling convention and accept only one single parameter, a pointer to a character string as or a NULL pointer. If you e.g. want to connect to a network printer from a batch file you can write: "calldll winspool.drv AddPrinterConnectionA \\server\printerq". The ZIP file also contains calldllw.exe which is exactly the same except that it passes a unicode string instead of ansi. That version can only be used in Windows NT/2000/XP/2003.
作者: czl1378    时间: 2009-5-30 20:08

额。。好像不支持or运算...好想让CMD的黑色透明。。可惜..
作者: Batcher    时间: 2009-5-30 20:32     标题: 回复 8楼 的帖子

7楼那个试了没?
作者: czl1378    时间: 2009-5-31 10:19

7楼的不懂...下了,好像只支持String?
能不能高诉下用法。
作者: czl1378    时间: 2009-6-1 20:10

好像又更新了。
额、、帮俺问下。。怎么使cmd的背景透明。。俺英语不大好。

VB中使窗体透明的代码:
VB 窗口透明调节2007-01-07 04:56添加Slider控键.用于调节透明度

Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
  
   
   
Public Const GWL_EXSTYLE = (-20)
Public Const WS_EX_LAYERED = &H80000
Public Const LWA_ALPHA = &H2

Public Function TranslucentForm(frm As Form, TranslucenceLevel As Byte) As Boolean
SetWindowLong frm.hwnd, GWL_EXSTYLE, WS_EX_LAYERED
SetLayeredWindowAttributes frm.hwnd, 0, TranslucenceLevel, LWA_ALPHA
TranslucentForm = Err.LastDllError = 0
End Function


TranslucentForm 窗口名(me), 透明度大小(0-255)
TranslucentForm Me, Slider1.Value(例子)


改为批处理之后。。。

  1. @echo off&&setlocal EnableDelayedExpansion
  2. set GWL_EXSTYLE=-20
  3. set /a WS_EX_LAYERED =80000
  4. set /a LWA_ALPHA=2
  5. set /a LWA_COLORKEY=1
  6. ext\func.dll user32.dll GetForegroundWindow
  7. ::返回当前窗口句柄
  8. set "hnd=%errorlevel%"
  9. ext\func.dll user32.dll SetWindowLongA -d %hnd% -d %GWL_EXSTYLE% -x %WS_EX_LAYERED%
  10. echo %errorlevel%
  11. pause>nul
复制代码
返回句柄很正常。。可是下面就遇到了问题。。
作者: garyng    时间: 2012-1-21 01:09

回复 11# czl1378


    CMD 背景透明似乎不可能的~
作者: xuebin51207    时间: 2013-3-2 12:22

带指针的不行吗?
作者: cfwyy77_bat    时间: 2018-1-25 13:12

很强,作者原链接失效了 好像也不更新了。
作者: vbcnt    时间: 2018-1-26 14:51

厉害!!!!!!!!!!!!!!!!!!!!!!!!!!!!
作者: MangDong    时间: 2018-5-25 18:44

回复 7# tireless
谢谢,好不容易找到了




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2