*api函数声明
const lb_sethorizontalextent = &h194
private declare function sendmessage lib "user32" alias "sendmessagea" _ (byval hwnd as long, byval wmsg as long, byval wparam as long, _ lparam as any) as long
注释:调用
call sendmessage(list1.hwnd, lb_sethorizontalextent, 400, byval 0&)
注释:注意400是以象素为单位,你可以根据情况自行设定。
9、如何交换鼠标按键?
*api函数声明
declare function swapmousebutton& lib "user32" _ (byval bswap as long)
要交换鼠标按键,将bswap参数设置为true。要恢复正常设置,将bswap设置为false。 然后调用函数就可以交换和恢复鼠标按键了。
10、如何让窗体的标题条闪烁以引起用户注意?
在窗体中放一个timer控件timer1,设置其inteval=200
*api函数声明
private declare function flashwindow lib "user32" (byval hwnd as long, byval binvert as long) as long
注释:在窗体中写下如下代码:
private sub timer1_timer()
flashwindow me.hwnd, true
end sub
11、怎样找到鼠标指针的xy坐标?
*api函数声明
type pointapi
x as long
y as long
end type
declare function getcursorpos lib "user32" (lppoint as pointapi) as long
调用:
getcursorpos z
print z.x
print z.y
12、怎样获得和改变双击鼠标的时间间隔?
获得鼠标双击间隔时间:
public declare function getdoubleclicktime lib "user32" alias _ "getdoubleclicktime" () as long
获得鼠标双击间隔时间:
declare function setdoubleclicktime lib "user32" alias "setdoubleclicktime" (byval wcount as long) as long
注释:注意:这种改变将影响到整个操作系统
以上两个函数都可精确到毫秒级。
13、在程序中如何打开和关闭光驱门?
*api函数声明如下:
private declare function mcisendstring lib "winmm.dll" alias "mcisendstringa" (byval lpstrcommand as string, byval lpstrreturnstring as string, byval ureturnlength as long, byval hwndcallback as long) as long
注释:调用时的代码如下
dim ret as long
dim retstr as string
注释:打开光驱门
ret = mcisendstring("set cdaudio door open", retstr, 0, 0)
注释:关闭光驱门
ret = mcisendstring("set cdaudio door closed", retstr, 0, 0)
14、如何获得windows启动方式?
在form1中加入一个commandbutton、一个label并加入如下代码:
private declare function getsystemmetrics lib "user32" (byval nindex as long) as long
const sm_cleanboot = 67
private sub command1_click()
select case getsystemmetrics(sm_cleanboot)
case 1
label1 = "安全模式."
case 2
label1 = "支持网络的安全模式."
case else
label1 = "windows运行在普通模式."
end select
end sub
15、怎样使ctrl-alt-delete无效?
*api函数声明
private declare function systemparametersinfo lib "user32" alias "systemparametersinfoa" (byval uaction as long, byval uparam as long, byval lpvparam as any, byval fuwinini as long) as long
编写如下函数:
sub disablectrlaltdelete(bdisabled as boolean)
dim x as long
x = systemparametersinfo(97, bdisabled, cstr(1), 0)
end sub
使ctrl-alt-delete无效 :