|
楼主 |
发表于 7-8-2006 06:56 PM
|
显示全部楼层
回复 #40 meemee 的帖子
microsoft spyxx? 没用过。 serching 时差不多全部的 site 都有提到,但我没见过也没用过。是跟 VC++ 一起的吗?
怎样用?
用 FindWindowEx 加 loop 是不是能找到一个"母窗口"下的 所有 "子窗口"? |
|
|
|
|
|
|
|
楼主 |
发表于 7-8-2006 07:17 PM
|
显示全部楼层
Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Declare Function ChildWindowFromPoint Lib "user32" (ByVal hWnd As Long, ByVal xPoint As Long, ByVal yPoint As Long) As Long
test_hwnd = FindWindow(ByVal 0&, "parent window")
test_DC = GetDC(test_hwnd)
child_hwnd = ChildWindowFromPoint(test_hwnd, 352, 588)
Picture1.Cls
Picture1.Print "hWnd = " & test_hwnd & " " & "hDC = " & test_DC
Picture1.Print "Chwnd = " & child_hwnd
SendMessageByString child_hwnd, WM_SETTEXT, 0, ByVal testString <--- 这里变成改 parent window title...why?
我如果先按一下 (352,588) 再用 sendkeys testString 的话就没问题。。。
(352,588) 是对话框(输入msg的地方)的其中一个坐标点,对话框是在 test_hwnd 里面。
[ 本帖最后由 BillyG 于 7-8-2006 07:20 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 8-8-2006 05:32 PM
|
显示全部楼层
回复 #41 BillyG 的帖子
emm...对。。。它是跟vc++一起来的。。。
13楼用的"AfxFrameOrView42","AfxFrameOrView42u","Afx:1000000:8",就是用这个tools找到的。。。
FindWindowEx不能找到childwindow,因为,我们不知道它的class name或window name。。。
你可以试试GetWindow。。。不过,msdn建议用EnumChildWindows,因为EnumChildWindows比较reliable。。。 |
|
|
|
|
|
|
|
发表于 8-8-2006 05:45 PM
|
显示全部楼层
回复 #42 BillyG 的帖子
这个,还不知道原因。。。
Picture1得到的答案。。。child_hwnd和test_hwnd一样吗?
如果,一样,那么表示,拿不到childwindow的handle。。。
如果,不一样,那么可能那个childwindow还没focus。。。你试试用setfocus,SetActiveWindow。。。 |
|
|
|
|
|
|
|
楼主 |
发表于 9-8-2006 12:26 AM
|
显示全部楼层
回复 #44, #45 meemee 的帖子
好那我研究一下 EnumChildWindows。
child_hwnd和test_hwnd 果然是一样。。。那怎办?我 ChildWindowFromPoint 用法有误吗?
问题:
用 SendMessage 和 PostMessage 这样一直 message 会不会造成目标窗口瘫痪(占用过多资源)?
PostMessage HwndFlash, WM_LBUTTONDOWN, MK_LBUTTON, ByVal MousePos
PostMessage HwndFlash, WM_LBUTTONUP, 0&, ByVal MousePos
上面两 line 能换成用SendMessage 吗?我用 SendMessage 鼠标有动但却没按下。
SendMessageByString child_hwnd, WM_SETTEXT, 0, ByVal testString
PostMessage 也能 SETTEXT 吗?
p/s:
SendMessage和PostMessage,的不同点是前者,必须等到那个被SendMessage的对象process完那个指令才执行下一个指令,后者,不需要等。。。就直接执行下一个指令。。。
网上也读到很多就是不明白,昨晚观察了我的 program 的运作才明白,也看见利与弊。:
[ 本帖最后由 BillyG 于 9-8-2006 12:33 AM 编辑 ] |
|
|
|
|
|
|
|
发表于 9-8-2006 09:52 AM
|
显示全部楼层
回复 #45 BillyG 的帖子
child_hwnd和test_hwnd 果然是一样。。。那怎办?我 ChildWindowFromPoint 用法有误吗?
应该没错误。。。或者,在ChildWindowFromPoint之前,作setfocus,SetActiveWindow的动作先。。。
用 SendMessage 和 PostMessage 这样一直 message 会不会造成目标窗口瘫痪(占用过多资源)?
用太多SendMessage可能会瘫痪。。。因为,SendMessage必须等到目标process完那个message,你才可以process下一个指令。。。
至于,PostMessage的话,那个目标还来不极process的话,就会被skip掉。。。
上面两 line 能换成用SendMessage 吗?我用 SendMessage 鼠标有动但却没按下。
可以。。。
PostMessage 也能 SETTEXT 吗?
应该可以,不过,SendMessage会比较好。。。 |
|
|
|
|
|
|
|
楼主 |
发表于 20-8-2006 02:31 PM
|
显示全部楼层
meemee,
我用了 spy 发现我的 target 窗口没有 子窗口 。。。 难怪会一样。。。
我又有新问题 了 。。。
是关于 GetDriveInfo() 的。
我在网上找到一些帖(由于太长所以只贴 URL)
http://chinese.cari.com.my/myforum/viewthread.php?tid=548699&extra=&page=2
第十二楼的帖 Private Function GetDriveInfo(drvNumber As IDE_DRIVE_NUMBER) As DRIVE_INFO
Dim hDrive As Long
Dim di As DRIVE_INFO
hDrive = SmartOpen(drvNumber)
If hDrive <> INVALID_HANDLE_VALUE Then
MsgBox "hDrive = true " & "hDrive = " & hDrive
If SmartGetVersion(hDrive) = True Then <-- 这里拿到false
MsgBox "SmartGetVersion = true"
With di
.bDriveType = 0
.NumAttributes = 0
ReDim .Attributes(0)
.bDriveType = 1
End With
If SmartCheckEnabled(hDrive, drvNumber) Then
MsgBox "Smart Check Enable = true"
If IdentifyDrive(hDrive, IDE_ID_FUNCTION, drvNumber, di) = True Then
MsgBox "Identify Drive = true"
GetDriveInfo = di
End If 'IdentifyDrive
End If 'SmartCheckEnabled
End If 'SmartGetVersion
End If 'hDrive <> INVALID_HANDLE_VALUE
CloseHandle hDrive
End Function
当我用时发现我两架 桌面电脑 只有一架能拿到 info, 另一架 拿不到 info.
拿不到 info 的那一架的 HDD 是 connect 到由 HT37x Raid IC 提供的 IDE.
我 debug 时发现能拿到 hDrive(handle) 但却拿不到 SmartGetVersion(Boolean),而 SmartGetVersion 是由 DeviceIoControl() determind 的。。。
Private Declare Function DeviceIoControl Lib "kernel32" (ByVal hDevice As Long, ByVal dwIoControlCode As Long, lpInBuffer As Any, ByVal nInBufferSize As Long, lpOutBuffer As Any, ByVal nOutBufferSize As Long, lpBytesReturned As Long, ByVal lpOverlapped As Long) As Long
想问 为设么 DeviceIoControl check 不到 Smart Drive 呢?(我的 HDD 是 Seagate 72000.x SATA 的, 应该是有 Smart Drive 的。是不是 RAID chip 的关系呢?如是要怎样才能 get info for HDD on Raid 呢? |
|
|
|
|
|
|
|
发表于 20-8-2006 02:53 PM
|
显示全部楼层
回复 #47 BillyG 的帖子
http://chinese.cari.com.my/myforum/viewthread.php?tid=548699&extra=&page=2
呵呵。。。你贴错网址了。。。548699是这个帖的tid。。。忙中有错??
DeviceIoControl()是kernel级的操作。。。用什么os。。。win98,winXP或win2k?
有没有administrator的permission? |
|
|
|
|
|
|
|
楼主 |
发表于 20-8-2006 04:06 PM
|
显示全部楼层
补贴
http://www.dbforums.com/showthread.php?t=876711&page=1&pp=15
"paiseh" |
|
|
|
|
|
|
|
楼主 |
发表于 20-8-2006 04:10 PM
|
显示全部楼层
回复 #48 meemee 的帖子
用 XP , 有 administrator 的 permission,因为本身就是 administrator (default Acc). |
|
|
|
|
|
|
|
楼主 |
发表于 22-8-2006 09:25 PM
|
显示全部楼层
Private Declare Function DeviceIoControl Lib "kernel32" (ByVal hDevice As Long, ByVal dwIoControlCode As Long, lpInBuffer As Any, ByVal nInBufferSize As Long, lpOutBuffer As Any, ByVal nOutBufferSize As Long, lpBytesReturned As Long, ByVal lpOverlapped As Long) As Long
Private Function SmartGetVersion(ByVal hDrive As Long) As Boolean
Dim cbBytesReturned As Long
Dim GVOP As GETVERSIONOUTPARAMS
SmartGetVersion = DeviceIoControl(hDrive, _
DFP_GET_VERSION, _
ByVal 0&, 0, _
GVOP, _
Len(GVOP), _
cbBytesReturned, _
ByVal 0&)
End Function
SmartGetVersion(hDrive) <-- 在怎样的情形下 SmartGetVersion(hDrive) = false?
DeviceIoControl( hDevice, dwIoControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped) <-- 这里的 parameters 都用作舍么用途?都 return 些舍么资料? |
|
|
|
|
|
|
|
发表于 23-8-2006 03:47 PM
|
显示全部楼层
回复 #51 BillyG 的帖子
暂时帮你答这个。。。
47楼的问题嘛。。。有看过别人用同样的方式 (smart) 成功的在 sata 读到硬碟的serial number。。。他是用是 c 。。。你可以试试下载他写好的exe来test。。。最近,被公司的工作烦死了。。。也没时间帮你。。。
http://forum.sysinternals.com/fo ... D=6643&get=last
**********************************************************************
- DeviceIoControl( hDevice, dwIoControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped)
复制代码
hDevice 是handle。。。通过createfile来得到。。。
hDevice = CreateFile("\\.\PhysicalDrive" _
& CStr(drv_num), _
GENERIC_READ Or GENERIC_WRITE, _
FILE_SHARE_READ Or FILE_SHARE_WRITE, _
ByVal 0&, OPEN_EXISTING, 0, 0)
dwIoControlCode 是command code。。。
lpInBuffer, lpOutBuffer,lpBytesReturned, lpOverlapped 这些有lp的这些东西都是pointer。。。lp应该是long pointer的意思。。。
vb6不能支持pointer。。。因此,需要用byref来declare。。。如果,不用byref的话,就需要调用copymemory。。。直接用memory address里读取数据,然后copy去variable。。。
你再参考49楼的帖。。。那里有用了copymemory。。。
lpInBuffer 是input buffer。。。里面有你input的parameter的数据。。。
nInBufferSize 是input buffer的size。。。到底有多少byte。。。
通常,我们都用nInBufferSize = len(lpInBuffer)
lpOutBuffer和nOutBufferSize就是跟前者相反。。。这个是output...
lpBytesReturned 这个告诉你,你的output (lpOutBuffer) 是多少byte。。。
最后一个,我就不是很清楚它的用途。。。
[ 本帖最后由 meemee 于 23-8-2006 03:56 PM 编辑 ] |
|
|
|
|
|
|
|
楼主 |
发表于 23-8-2006 06:50 PM
|
显示全部楼层
回复 #52 meemee 的帖子
哦 原来是 pointer 所以才用 copymemory 明白了。我知道有 Regs 的变量是 registry stack 却没联想到 lp 是指 pointer.
我找到两个 site 有解说 DeviceIoControl() 贴上来研究研究
想问 #47 楼里的 DFP_RECEIVE_DRIVE_DATA = &H7C088 (dwIoControlCode) 的真正 command ( IOCTL_ / FSCTL_ ) 全名 是舍么?(&H7C088 = 舍么全名)
p/s : 你忙你的工作先,我不急。谢谢! |
|
|
|
|
|
|
|
发表于 25-8-2006 12:19 PM
|
显示全部楼层
其实,整个IOCTL commands是由4个部分组成
#define IOCTL_Device_Function CTL_CODE(DeviceType, Function, Method, Access)
[size=-1]- 'IOCTL commands
- Public Const DFP_GET_VERSION = &H74080
- Public Const DFP_SEND_DRIVE_COMMAND = &H7C084
- Public Const DFP_RECEIVE_DRIVE_DATA = &H7C088
复制代码
- // #define DFP_RECEIVE_DRIVE_DATA 0x0007c088
- #define DFP_RECEIVE_DRIVE_DATA CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
- //CTL_CODE的macro
- #define CTL_CODE( DeviceType, Function, Method, Access ) ( \
- ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
- )
复制代码
- //Access
- #define FILE_READ_ACCESS ( 0x0001 ) // file & pipe
- #define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe
- //Device Type
- #define FILE_DEVICE_DISK 0x00000007
- #define IOCTL_DISK_BASE FILE_DEVICE_DISK
- //Method
- #define METHOD_BUFFERED 0
- #define METHOD_IN_DIRECT 1
- #define METHOD_OUT_DIRECT 2
- #define METHOD_NEITHER 3
- #define SMART_GET_VERSION CTL_CODE(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS)
- #define SMART_SEND_DRIVE_COMMAND CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
- #define SMART_RCV_DRIVE_DATA CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
复制代码
- DFP_RECEIVE_DRIVE_DATA = &H7C088
复制代码
7C088[size=-1]16 = 0111 1100 0000 1000 1000[size=-1]2
DeviceType = 0111[size=-1]2 = 7 = IOCTL_DISK_BASE
Access = 11[size=-1]2 = 3 = FILE_READ_ACCESS | FILE_WRITE_ACCESS
Function = 1000 10[size=-1]2 = 22[size=-1]16 这个只有M$自己才知道
Method = 00[size=-1]2 = METHOD_BUFFERED
[ 本帖最后由 meemee 于 25-8-2006 12:25 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 25-8-2006 03:36 PM
|
显示全部楼层
[size=-1]- #define SMART_GET_VERSION CTL_CODE(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS)
- #define SMART_SEND_DRIVE_COMMAND CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
- #define SMART_RCV_DRIVE_DATA CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
复制代码
SMART_GET_VERSION:
DeviceType = IOCTL_DISK_BASE = 7 = 0111[size=-1]2
Access = FILE_READ_ACCESS = 1 = 01[size=-1]2
Function = 20[size=-1]16 = 1000 00[size=-1]2
Method = METHOD_BUFFERED = 00[size=-1]2
SMART_GET_VERSION <= DFP_GET_VERSION
= 01110100 0000 1000 0000[size=-1]2
= 74080[size=-1]16
SMART_SEND_DRIVE_COMMAND <= DFP_SEND_DRIVE_COMMAND
= 01111100 0000 1000 0100[size=-1]2
= 7C084[size=-1]16
SMART_RCV_DRIVE_DATA <= DFP_RECEIVE_DRIVE_DATA
= 01111100 0000 1000 1000[size=-1]2
= 7C088[size=-1]16
SMART_GET_VERSION
Operation
Returns version information, a capabilities mask, and a bitmask for the device. This IOCTL must be handled by drivers that support Self-Monitoring Analysis and Reporting Technology (SMART).
Input
Parameters.DeviceIoControl.OutputBufferLength indicates the size in bytes of the buffer, which must be >= sizeof(GETVERSIONINPARAMS).
Output
The driver returns the information to the buffer at Irp->AssociatedIrp.SystemBuffer.
I/O Status Block
The driver sets the Information field to sizeof(GETVERSIONINPARAMS) when it sets the Status field to STATUS_SUCCESS. Otherwise, the driver sets the Information field to zero and sets the Status field to possibly STATUS_INVALID_PARAMETER.
这是IOCTL_DISK_BASE定义:
#define FILE_DEVICE_DISK 0x00000007
#define IOCTL_DISK_BASE FILE_DEVICE_DISK
[ 本帖最后由 meemee 于 25-8-2006 04:36 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 25-8-2006 03:38 PM
|
显示全部楼层
[size=-1]完整的device type:
- #define FILE_DEVICE_BEEP 0x00000001
- #define FILE_DEVICE_CD_ROM 0x00000002
- #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
- #define FILE_DEVICE_CONTROLLER 0x00000004
- #define FILE_DEVICE_DATALINK 0x00000005
- #define FILE_DEVICE_DFS 0x00000006
- #define FILE_DEVICE_DISK 0x00000007
- #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
- #define FILE_DEVICE_FILE_SYSTEM 0x00000009
- #define FILE_DEVICE_INPORT_PORT 0x0000000a
- #define FILE_DEVICE_KEYBOARD 0x0000000b
- #define FILE_DEVICE_MAILSLOT 0x0000000c
- #define FILE_DEVICE_MIDI_IN 0x0000000d
- #define FILE_DEVICE_MIDI_OUT 0x0000000e
- #define FILE_DEVICE_MOUSE 0x0000000f
- #define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
- #define FILE_DEVICE_NAMED_PIPE 0x00000011
- #define FILE_DEVICE_NETWORK 0x00000012
- #define FILE_DEVICE_NETWORK_BROWSER 0x00000013
- #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
- #define FILE_DEVICE_NULL 0x00000015
- #define FILE_DEVICE_PARALLEL_PORT 0x00000016
- #define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
- #define FILE_DEVICE_PRINTER 0x00000018
- #define FILE_DEVICE_SCANNER 0x00000019
- #define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
- #define FILE_DEVICE_SERIAL_PORT 0x0000001b
- #define FILE_DEVICE_SCREEN 0x0000001c
- #define FILE_DEVICE_SOUND 0x0000001d
- #define FILE_DEVICE_STREAMS 0x0000001e
- #define FILE_DEVICE_TAPE 0x0000001f
- #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
- #define FILE_DEVICE_TRANSPORT 0x00000021
- #define FILE_DEVICE_UNKNOWN 0x00000022
- #define FILE_DEVICE_VIDEO 0x00000023
- #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
- #define FILE_DEVICE_WAVE_IN 0x00000025
- #define FILE_DEVICE_WAVE_OUT 0x00000026
- #define FILE_DEVICE_8042_PORT 0x00000027
- #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
- #define FILE_DEVICE_BATTERY 0x00000029
- #define FILE_DEVICE_BUS_EXTENDER 0x0000002a
- #define FILE_DEVICE_MODEM 0x0000002b
- #define FILE_DEVICE_VDM 0x0000002c
- #define FILE_DEVICE_MASS_STORAGE 0x0000002d
- #define FILE_DEVICE_SMB 0x0000002e
- #define FILE_DEVICE_KS 0x0000002f
- #define FILE_DEVICE_CHANGER 0x00000030
- #define FILE_DEVICE_SMARTCARD 0x00000031
- #define FILE_DEVICE_ACPI 0x00000032
- #define FILE_DEVICE_DVD 0x00000033
- #define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034
- #define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035
- #define FILE_DEVICE_DFS_VOLUME 0x00000036
- #define FILE_DEVICE_SERENUM 0x00000037
- #define FILE_DEVICE_TERMSRV 0x00000038
- #define FILE_DEVICE_KSEC 0x00000039
- #define FILE_DEVICE_FIPS 0x0000003A
- #define FILE_DEVICE_INFINIBAND 0x0000003B
复制代码
一部份的IOCTL_DISK_BASE指令:
- #define IOCTL_DISK_BASE FILE_DEVICE_DISK
- #define IOCTL_DISK_GET_DRIVE_GEOMETRY CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS)
- #define IOCTL_DISK_GET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
- #define IOCTL_DISK_SET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
- #define IOCTL_DISK_GET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
- #define IOCTL_DISK_SET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
- #define IOCTL_DISK_VERIFY CTL_CODE(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, FILE_ANY_ACCESS)
- #define IOCTL_DISK_FORMAT_TRACKS CTL_CODE(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
- #define IOCTL_DISK_REASSIGN_BLOCKS CTL_CODE(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
- #define IOCTL_DISK_PERFORMANCE CTL_CODE(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
- #define IOCTL_DISK_IS_WRITABLE CTL_CODE(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, FILE_ANY_ACCESS)
- #define IOCTL_DISK_LOGGING CTL_CODE(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, FILE_ANY_ACCESS)
- #define IOCTL_DISK_FORMAT_TRACKS_EX CTL_CODE(IOCTL_DISK_BASE, 0x000b, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
- #define IOCTL_DISK_HISTOGRAM_STRUCTURE CTL_CODE(IOCTL_DISK_BASE, 0x000c, METHOD_BUFFERED, FILE_ANY_ACCESS)
- #define IOCTL_DISK_HISTOGRAM_DATA CTL_CODE(IOCTL_DISK_BASE, 0x000d, METHOD_BUFFERED, FILE_ANY_ACCESS)
- #define IOCTL_DISK_HISTOGRAM_RESET CTL_CODE(IOCTL_DISK_BASE, 0x000e, METHOD_BUFFERED, FILE_ANY_ACCESS)
- #define IOCTL_DISK_REQUEST_STRUCTURE CTL_CODE(IOCTL_DISK_BASE, 0x000f, METHOD_BUFFERED, FILE_ANY_ACCESS)
- #define IOCTL_DISK_REQUEST_DATA CTL_CODE(IOCTL_DISK_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
- #define IOCTL_DISK_PERFORMANCE_OFF CTL_CODE(IOCTL_DISK_BASE, 0x0018, METHOD_BUFFERED, FILE_ANY_ACCESS)
- #define IOCTL_DISK_CONTROLLER_NUMBER CTL_CODE(IOCTL_DISK_BASE, 0x0011, METHOD_BUFFERED, FILE_ANY_ACCESS)
- #define IOCTL_DISK_GET_PARTITION_INFO_EX CTL_CODE(IOCTL_DISK_BASE, 0x0012, METHOD_BUFFERED, FILE_ANY_ACCESS)
- #define IOCTL_DISK_SET_PARTITION_INFO_EX CTL_CODE(IOCTL_DISK_BASE, 0x0013, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
- #define IOCTL_DISK_GET_DRIVE_LAYOUT_EX CTL_CODE(IOCTL_DISK_BASE, 0x0014, METHOD_BUFFERED, FILE_ANY_ACCESS)
- #define IOCTL_DISK_SET_DRIVE_LAYOUT_EX CTL_CODE(IOCTL_DISK_BASE, 0x0015, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
- #define IOCTL_DISK_CREATE_DISK CTL_CODE(IOCTL_DISK_BASE, 0x0016, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
- #define IOCTL_DISK_GET_LENGTH_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0017, METHOD_BUFFERED, FILE_READ_ACCESS)
- #define IOCTL_DISK_GET_DRIVE_GEOMETRY_EX CTL_CODE(IOCTL_DISK_BASE, 0x0028, METHOD_BUFFERED, FILE_ANY_ACCESS)
- #define IOCTL_DISK_UPDATE_DRIVE_SIZE CTL_CODE(IOCTL_DISK_BASE, 0x0032, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
- #define IOCTL_DISK_GROW_PARTITION CTL_CODE(IOCTL_DISK_BASE, 0x0034, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
- #define IOCTL_DISK_GET_CACHE_INFORMATION CTL_CODE(IOCTL_DISK_BASE, 0x0035, METHOD_BUFFERED, FILE_READ_ACCESS)
- #define IOCTL_DISK_SET_CACHE_INFORMATION CTL_CODE(IOCTL_DISK_BASE, 0x0036, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
- #define IOCTL_DISK_GET_WRITE_CACHE_STATE CTL_CODE(IOCTL_DISK_BASE, 0x0037, METHOD_BUFFERED, FILE_READ_ACCESS)
- #define IOCTL_DISK_DELETE_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0040, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
- #define IOCTL_DISK_UPDATE_PROPERTIES CTL_CODE(IOCTL_DISK_BASE, 0x0050, METHOD_BUFFERED, FILE_ANY_ACCESS)
- #define IOCTL_DISK_CHECK_VERIFY CTL_CODE(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
- #define IOCTL_DISK_MEDIA_REMOVAL CTL_CODE(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
- #define IOCTL_DISK_EJECT_MEDIA CTL_CODE(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
- #define IOCTL_DISK_LOAD_MEDIA CTL_CODE(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
- #define IOCTL_DISK_RESERVE CTL_CODE(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
- #define IOCTL_DISK_RELEASE CTL_CODE(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
- #define IOCTL_DISK_FIND_NEW_DEVICES CTL_CODE(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
- #define IOCTL_DISK_GET_MEDIA_TYPES CTL_CODE(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
复制代码
[ 本帖最后由 meemee 于 25-8-2006 03:40 PM 编辑 ] |
|
|
|
|
|
|
|
楼主 |
发表于 5-9-2006 12:39 AM
|
显示全部楼层
謝謝 meemee,
明白了,
现在想问 下面的 postmessage 出啥问题?
Sub reply()
Dim answers As String
Dim x As Integer
answers = "ABCDEFGHIJKLMNOPQRSTUVWSYZ!@#$%^&*()"
For x = 1 To Len(answers)
PostMessage test_hwnd, WM_KEYDOWN, Asc(Mid$(answers, i, 1)), 0
PostMessage test_hwnd, WM_KEYUP, 0, 0
Next
PostMessage test_hwnd, WM_KEYDOWN, VK_RETURN, 0
PostMessage test_hwnd, WM_KEYUP, 0, 0
End Sub
为啥 (PostMessage test_hwnd, WM_KEYDOWN, Asc(Mid$(answers, i, 1)), 0) 会output 奇怪的符号?
Asc("I") = 73 ,
Asc("i") = 105,
为啥
(PostMessage test_hwnd, WM_KEYDOWN, Asc("I"), 0) = i ?
(PostMessage test_hwnd, WM_KEYDOWN, Asc("i"), 0) = i ? |
|
|
|
|
|
|
|
发表于 6-9-2006 10:25 AM
|
显示全部楼层
回复 #57 BillyG 的帖子
当然有错误,你的 i 从哪里跑出来。。。
[size=-1]Sub reply()
Dim answers As String
Dim x As Integer
answers = "ABCDEFGHIJKLMNOPQRSTUVWSYZ!@#$%^&*()"
For x = 1 To Len(answers)
PostMessage test_hwnd, WM_KEYDOWN, Asc(Mid$(answers, i, 1)), 0
PostMessage test_hwnd, WM_KEYUP, 0, 0
Next
PostMessage test_hwnd, WM_KEYDOWN, VK_RETURN, 0
PostMessage test_hwnd, WM_KEYUP, 0, 0
End Sub
别的问题,暂时还没发现。。。还没试过compile
[ 本帖最后由 meemee 于 6-9-2006 10:26 AM 编辑 ] |
|
|
|
|
|
|
|
楼主 |
发表于 6-9-2006 02:31 PM
|
显示全部楼层
回复 #58 meemee 的帖子
lol , 没注意到。原本不是用x是用i的,因为想用i和I做string问问题所以改了一点点但改漏了.哈哈。
PostMessage test_hwnd, WM_KEYDOWN, Asc(Mid$(answers, x, 1)), 0
这样还是会出奇怪符号(头一个字母能出,不过是小号,其他后面的字母都出成奇怪符号)
(PostMessage test_hwnd, WM_KEYDOWN, Asc("I"), 0) = i ?
(PostMessage test_hwnd, WM_KEYDOWN, Asc("i"), 0) = i ?
这里,为啥“i”和“I”都会 postmessage 成“i”呢?
Asc(string) <-- 是不是只限定 output 所有小号(没按shiftkey)的 keyboard 符号呢?
另外:
Sub reply()
Dim answers As String
Dim x As Integer
Dim xyz As Byte
answers = "ABCDEFGHIJKLMNOPQRSTUVWSYZ!@#$%^&*()"
xyz = answers
For x = 1 To LenB(answers) Step2
PostMessage test_hwnd, WM_KEYDOWN, VkKeyScan(xyz(x)), 0
PostMessage test_hwnd, WM_KEYUP, 0, 0
Next
PostMessage test_hwnd, WM_KEYDOWN, VK_RETURN, 0
PostMessage test_hwnd, WM_KEYUP, 0, 0
End Sub
这个也是出小号(没出奇怪符号)。why?
[ 本帖最后由 BillyG 于 6-9-2006 03:01 PM 编辑 ] |
|
|
|
|
|
|
|
楼主 |
发表于 6-9-2006 03:26 PM
|
显示全部楼层
还有。。
LTrim$, RTrim$ 和 Trim$
我用 Trim$(di.SerialNumber) 可是有时清除不了右边的空格。
比如:
di.SerialNumber = "WD-XYZ123456789 "
我 Len(Trim$(di.SerialNumber)) 或 Len(RTrim$(di.SerialNumber)) 都 = 20
有时(不同电脑,相同 HDD brand)又能,会 = 15.
为什么?
再来。。
abc = "WD-XYZ123456789 "
xyz = "WD-XYZ123456789 "
if abc = xyz then
msgbox "true"
else
msgbox "false"
endif
为什么会得到 "false"
而。。。
abc = "WD-XYZ123456789"
xyz = "WD-XYZ123456789"
if abc = xyz then
msgbox "true"
else
msgbox "false"
endif
却会得到 "true". 为什么?
***di is HDD info read from DeviceIoControl function |
|
|
|
|
|
|
| |
本周最热论坛帖子
|