当前位置:编程学习 > VB >>

VB涓皟鐢ˋPI鍑芥暟閮芥湁浠€涔堟妧宸э紵 - 宸茶В鍐?- 鎼滄悳闂棶

答案:
鍏充簬API鍑芥暟鐨勪功!甯傚満涓婂お灏戜簡!灏辩畻鏄湁,涔熶粙缁嶅緱寰堢矖娴?浣犲埌涔﹀簵濂藉ソ鎵炬壘!鎴戞病鏈堿PI鍑芥暟鐨勫ソ涔︿粙缁嶇粰浣? 
璋堜竴涓嬫垜鐨勫績寰楀惂:
棣栧厛锛屾湁蹇呰鍚戝ぇ瀹惰涓€璁诧紝浠€涔堟槸API銆侫PI鏄寘鍚湪涓€涓檮鍔犲悕涓篋LL鐨勫姩鎬佽繛鎺ュ簱鏂囦欢涓殑銆傜敤鏍囧噯鐨勫畾涔夋潵璁诧紝API灏辨槸Windows鐨?2浣嶅簲鐢ㄧ▼搴忕紪绋嬫帴鍙o紝鏄竴绯诲垪寰堝鏉傜殑鍑芥暟锛屾秷鎭拰缁撴瀯锛屽彲浠ヨ锛屽鏋滀綘鏇剧粡瀛﹁繃VC锛岄偅涔圓PI瀵逛綘鏉ヨ涓嶆槸浠€涔堥棶棰樸€備絾鏄鏋滀綘娌℃湁瀛﹁繃VC锛屾垨鑰呬綘瀵筗indows95鐨勭粨鏋勪綋绯讳笉鐔熸倝锛岄偅涔堝彲浠ヨ锛屽涔燗PI灏嗘槸涓€浠跺緢杈涜嫤鐨勪簨鎯呫€?

濡傛灉浣犳墦寮€WINDOWS鐨凷YSTEM鏂囦欢澶癸紝浣犲彲浠ュ彂鐜板叾涓湁寰堝闄勫姞鍚嶄负DLL鐨勬枃浠躲€備竴涓狣LL涓寘鍚殑API鍑芥暟骞朵笉鍙槸涓€涓紝鏁板崄涓紝API鍑芥暟鎬诲叡澶х害鏈?10澶氫釜銆傚鏋滆鍏ㄩ儴鎺屾彙!閭d綘闈炰笅鑻﹀姛涓嶅彲,浣嗗疄闄呬笂锛屾垜浠湡鐨勬病蹇呰閮芥帉鎻★紝鍙閲嶇偣鎺屾彙Windos绯荤粺鏈韩鑷甫鐨凙PI鍑芥暟灏卞彲浠ヤ簡銆傛垜鍙互鏁㈣窡浣犺锛屽彧瑕佷綘鐔熸倝鍦版帉鎻?00涓紝閭d箞浣犵殑缂栫▼姘村钩姣旂幇鍦ㄩ珮鍑鸿嚦灏戣涓ゅ€嶃€侫PI鍑芥暟鍜學INDOWS鍏锋湁瀵嗗垏鐨勫叧绯伙紝濡傛灉浣犲浼氫簡API锛岄瑕佺殑鏀惰幏渚挎槸瀵筗INDOWS浣撶郴缁撴瀯鐨勮璇嗐€傝繖涓敹鑾锋槸鏉ヨ嚜涓嶆槗鐨勩€?

濡傛灉浣犱笉渚濋潬API浼氭€庝箞鏍?鎴戝彲浠ヨ窡浣犺锛岀粷澶у鏄珮绾х紪绋嬩功鏈?褰撶劧杩欎笉鏄功鐨勫悕绋嬪彨楂樼骇鑰岄珮绾х殑锛岃€屾槸鍦ㄤ竴寮€濮嬬殑銆婃湰涔﹀唴瀹广€嬩腑鎸囨槑銆婃湰涔︾殑闃呰瀵硅薄鏄叿鏈変竴瀹歏B鍩虹鐨勮鑰呫€嬬殑閭d簺涔?锛岄鍏堟彁鐨勯棶棰樹竴鑸ぇ閮芥槸浠嶢PI寮€濮嬨€傚洜姝ゅ彲浠ヨ锛屼綘涓嶅API锛屼綘澶ф灏嗗仠鐣欏湪鍒濈骇姘村钩锛屾棤娉曞線涓婃攢鐧汇€?

寰堝API鍑芥暟閮芥槸寰堥暱寰堥暱鐨勩€傛兂鐪嬩粈涔堟牱瀛愬悧?濡備笅灏辨槸浣滀负渚嬪瓙鐨凙PI DdeClientTransaction鍑芥暟鈭?
Declare Function DdeClientTransaction Lib "user32" (pData As Byte, ByVal cbData As Long, ByVal hConv As Long, ByVal hszItem As Long, ByVal wFmt As Long, ByVal wType As Long, ByVal dwTimeout As Long, pdwResult As Long) As Long
鍝囷紒杩欎箞闀?濡傛灉浣犱粠鏉ユ病鏈夋帴瑙﹁繃API锛屾垜鎯充綘鑲畾琚悡浣忎簡銆備綘涔熻鑰冭檻锛岃涓嶈缁х画瀛︿笅鍘汇€備笉杩囦笉瑕佹媴蹇冿紝骞歌繍鐨勬槸Microsoft鐨勮璁″浠负鎴戜滑鎻愪緵浜嗘湁鐢ㄧ殑宸ュ叿锛岃繖渚挎槸API
鏂囨湰鏌ョ湅鍣ㄣ€?

閫氳繃API鏂囨湰鏌ョ湅鍣紝鎴戜滑鍙互鏂逛究鍦版煡鎵剧▼搴忔墍闇€瑕佺殑鍑芥暟澹版槑銆佺粨鏋勭被鍨嬪拰甯告暟锛岀劧鍚庡皢瀹冨鍒跺埌鍓创鏉匡紝鏈€鍚庡啀绮樿创鍒癡B绋嬪簭鐨勪唬鐮佹涓€傚湪澶у鏁版儏鍐典笅锛屽彧瑕佹垜浠‘瀹氫簡绋嬪簭鎵€闇€瑕佺殑鍑芥暟銆佺粨鏋勫拰甯告暟杩欎笁涓柟闈㈠悗锛屽氨鍙互閫氳繃瀵笰PI鏂囨湰娓歌鍣ㄧ殑浠ヤ笂鎿嶄綔灏嗕粬浠姞鍏ュ埌绋嬪簭娈典腑锛屼粠鑰岀▼搴忎腑鍙互浣跨敤杩欎簺鍑芥暟浜嗐€傝繖浜涙槸瀛︿範API鏈€鍩烘湰鐨勫父璇嗛棶棰橈紝瀹冭繙杩滃崰涓嶅埌API鐨勫簽澶х殑浣撶郴鍐呭銆備粖鍚庢垜浠妸绮惧姏娴垂(杩欑粷涓嶆槸娴垂)鍦ㄥ摢閲屽憿?閭e氨鏄埗
浠€涔堟椂鍊欎娇鐢ㄤ粈涔堝嚱鏁帮紝浠€涔堟椂鍊欎娇鐢ㄤ粈涔堢粨鏋勭被鍨嬶紝浠€涔堟椂鍊欎娇鐢ㄤ粈涔堝父鏁般€?
API鍑芥暟澹版槑 [杩斿洖]

璁╂垜浠洖鎯充竴涓嬨€傚湪VB涓紝濡備綍澹版槑鍑芥暟鍛?鎴戞兂锛屽鏋滀綘姝e湪鐪嬫鏂囷紝閭d箞浣犵粷瀵硅兘澶熷洖绛斿緱鍑鸿繖涓棶棰樸€備互涓嬩究鏄綘搴旇寰堢啛鎮夌殑鍑芥暟澹版槑鈭?
Function SetWindowRgn Lib "user32"Alias "SetWindowRgn" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long

鍗筹紝杩欒浠g爜瀹氫箟浜嗗悕涓篠etWindowRgn鐨勫嚱鏁?姝ゅ嚱鏁板叿鏈変竴涓狶ong鍨嬫暟鎹被鍨嬬殑鍙傛暟锛屽苟鎸夊€间紶閫?ByVal),鍑芥暟鎵ц鍚庡皢杩斿洖涓€涓狶ong鍨嬫暟鎹€?
API鍑芥暟鐨勫0鏄庝篃寰堢被浼硷紝濡傦紝API涓殑SetWindowRgn 鍑芥暟鏄繖鏍峰啓鐨勨埗

Public Declare Function SetWindowRgn Lib "user32" Alias "SetWindowRgn" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long


Declare 璇彞鐢ㄤ簬鍦ㄦā鍧楃骇鍒腑澹版槑瀵瑰姩鎬侀摼鎺ュ簱 (DLL) 涓閮ㄨ繃绋嬬殑寮曠敤銆傚姝わ紝浣犲彧瑕佽浣忎换浣旳PI鍑芥暟澹版槑閮藉繀椤诲啓杩欎釜璇彞灏卞彲浠ヤ簡銆?
Iib 鎸囨槑鍖呭惈鎵€澹版槑杩囩▼鎴栧嚱鏁扮殑鍔ㄦ€侀摼鎺ュ簱鎴栦唬鐮佽祫婧愩€備篃灏辨槸璇达紝瀹冭鏄庣殑鏄紝鍑芥暟鎴栬繃绋嬩粠浣曡€屾潵鐨勯棶棰樸€?
濡傚湪涓婁緥涓紝SetWindowRgn Lib "user32"璇存槑 鍑芥暟 SetWindowRgn 鏉ヨ嚜 user32.dll鏂囦欢銆備富瑕佺殑dll鍔ㄦ€佽繛鎺ュ簱鏂囦欢鏈夆埗
user32.dll Windows绠$悊銆傜敓鎴愬拰绠$悊搴旂敤绋嬪簭鐨勭敤鎴锋帴鍙c€?

GDI32.dll 鍥惧舰璁惧鎺ュ彛銆備骇鐢焀indows璁惧鐨勫浘褰㈣緭鍑?
Kernel32.dll 绯荤粺鏈嶅姟銆傝闂搷浣滅郴缁熺殑璁$畻鏈鸿祫婧愩€?
娉ㄦ剰锛屽綋DLL鏂囦欢涓嶅湪Windows鎴朣ystem鏂囦欢澶逛腑鐨勬椂鍊欙紝蹇呴』鍦ㄥ嚱鏁颁腑璇存槑鍏跺嚭澶?
璺緞)銆傚锛孲etFocus Lib "c:\Mydll\user32"
鍑芥暟澹版槑涓殑Alias 鏄彲閫夌殑銆傝〃绀哄皢琚皟鐢ㄧ殑杩囩▼鍦ㄥ姩鎬侀摼鎺ュ簱 (DLL) 涓繕鏈夊彟澶栫殑鍚嶇О(鍒悕)銆傚锛孉lias "SetWindowRgn" 锛岃鏄嶴etWindowRgn鍑芥暟鍦║ser32.dll涓殑鍙﹀涓€涓悕绉版槸锛?
SetWindowRgn銆傛€庝箞涓や釜鍚嶉兘涓€鏍峰憿?褰撶劧锛屼篃鍙互鏄笉鍚岀殑銆傚湪寰堝鎯呭喌涓嬶紝Alias璇存槑鐨勫嚱鏁板悕锛屽嵆鍒悕鏈€鍚庝竴涓瓧绗︾粡甯告槸瀛楃A锛屽SetWindowsText鍑芥暟鐨勫彟涓€涓悕绉版槸
SetWindowsTextA,琛ㄧず涓篈lias "SetWindowsTextA"銆傝繖涓狝鍙笉杩囨槸璁捐瀹朵滑鐨勪範鎯殑鍛藉悕绾﹀畾锛岃〃绀哄嚱鏁板睘浜嶢NSI鐗堟湰銆?

闇€瑕佹敞鎰忕殑鏄紝涓嶆槸鎵€鏈夌殑API鍑芥暟閮芥湁鍒悕.閫夌敤Alias鐨勬椂鍊欙紝搴旀敞鎰忓埆鍚嶇殑澶у皬鍐欙紱濡傛灉涓嶉€夌敤Alias 鏃剁殑鏃跺€欙紝鍑芥暟鍚嶅繀椤绘敞鎰忓ぇ灏忓啓锛岃€屼笖涓嶈兘鏀瑰姩銆傚綋鐒讹紝鍦ㄥ緢澶氭儏鍐典笅锛岀敱浜庡嚱鏁板0鏄庢槸鐩存帴浠嶢PI
鏂囨湰娓歌鍣ㄤ腑鎷疯礉杩囨潵鐨勶紝鎵€浠ヨ繖绉嶉敊璇殑鍙戠敓鏈轰細鏄緢灏戠殑锛屼絾鎮ㄦ湁蹇呰鐭ラ亾杩欎竴鐐广€?
鏈€鍚庢彁閱掍綘涓€鍙ワ紝API澹版槑(鍖呮嫭缁撴瀯銆佸父鏁?蹇呴』鏀惧湪绐椾綋鎴栨ā鍧楃殑"閫氱敤(General Declarations)娈点€?
鏁版嵁绫诲瀷涓?绫诲瀷瀹夊叏" [杩斿洖]

API鍑芥暟涓娇鐢ㄧ殑鏁版嵁绫诲瀷鍩烘湰涓婂拰VB涓殑涓€鏍枫€備絾浣滀负WIN32鐨凙PI鍑芥暟涓紝涓嶅瓨鍦↖nteger
鏁版嵁绫诲瀷銆傚彟澶栦竴鐐规槸鍦ˋPI鍑芥暟涓湅涓嶅埌Boolean鏁版嵁绫诲瀷銆?Variant鏁版嵁绫诲瀷鍦ˋPI鍑芥暟涓槸浠ny鐨勫舰寮忓嚭鐜帮紝濡侱ata As Any銆傚敖绠″叾鍚箟鏄厑璁镐换鎰忓弬鏁扮被鍨嬩綔涓轰竴涓API鍑芥暟鐨勫弬鏁颁紶閫掞紝浣嗚繖鏍峰仛瀛樺湪涓€瀹氱殑缂虹偣銆傚叾鍘熷洜鏄紝杩欏皢浼氫娇寰楀鐩爣鍙傛暟鐨勬墍鏈夌被鍨嬫鏌ラ兘浼氳鍏抽棴銆傝繖鑷劧浼氱粰鍚勭绫诲瀷鐨勫弬鏁拌皟鐢ㄥ甫鏉ヤ簡浜х敓閿欒鐨勬満浼氥€?

瑕佸濂紸PI鍑芥暟,杩樺緱闈犺嚜宸卞幓鎱㈡參鐞㈢(,鍕ら捇鍕ょ粌,棰嗕細鍚勪釜API鍑芥暟鐨勫姛鑳藉拰鐢ㄦ硶!鍦ㄥ疄闄呭簲鐢ㄤ腑鑷劧浼氬緱蹇冨簲鎵?娓稿垉鏈変綑!

上一个:VB怎么做得到上次电脑关闭的时间?
下一个:怎么用VB做一个关于计算机的管理程序?

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,