Á˽â¾ä±ú
ÔÚµ÷Óà DLL º¯ÊýÇ°±ØÐëÀí½âµÄÁíÍâÒ»¸öÖØÒª¸ÅÄîÊǾä±ú¡£¾ä±úÊÇÒ»¸ö 32 λµÄÕýÕûÊý£¬Microsoft® Windows® ÓÃËüÀ´Ê¶±ð´°Ìå»òÆäËû¶ÔÏó£¬ÀýÈç×ÖÌå»òλͼ¡£ÔÚ Windows ÖУ¬´°¿Ú¿ÉÒÔÓÐÐí¶àÖÖ¡£´°¿Ú¿ÉÒÔÊÇÆÁÄ»ÉϵÄÒ»¿é¾ØÐηâ±ÕÇøÓò£¬±ÈÈçÄúÊìϤµÄÓ¦ÓóÌÐò´°¿Ú¡£´°ÌåÉϵĿؼþ£¨ÀýÈçÁбí¿ò»ò¹ö¶¯Ìõ£©Ò²¿ÉÒÔÊÇ´°¿Ú£¬µ«²¢²»ÊÇËùÓÐÀàÐ͵Ŀؼþ¶¼ÊÇ´°¿Ú¡£×ÀÃæÉϵÄͼ±êºÍ×ÀÃæ±¾ÉíÒ²ÊÇ´°¿Ú¡£ ÒòΪËùÓÐÕâЩÀàÐ͵ĶÔÏó¶¼ÊÇ´°¿Ú£¬ËùÒÔ Windows ¿ÉÒÔÓÃÀàËƵķ½Ê½´¦ÀíËüÃÇ¡£Windows ¸øÿ¸ö´°¿ÚÒ»¸öΨһµÄ¾ä±ú£¬Í¨¹ý¾ä±ú²Ù×ݸô°¿Ú¡£Ðí¶à API º¯Êý¿É·µ»Ø¾ä±ú»òÕß½ÓÊܾä±ú×÷²ÎÊý¡£ ´´½¨´°¿Úʱ£¬Windows ¸øËüÖ¸ÅÉÒ»¸ö¾ä±ú£¬´°¿ÚÏûʧºó¾ä±ú±»ÊÍ·Å¡£ËäÈ»¾ä±úÔÚ´°¿ÚµÄÕû¸öÉú´æÆÚÄÚ±£³Ö²»±ä£¬µ«²»Äܱ£Ö¤Ä³´°¿ÚÔÚ±»Ë𻵲¢ÖØд´½¨ºó»¹Ê¹ÓÃÔÀ´µÄ¾ä±ú¡£ËùÒÔ£¬Èç¹ûÔÚ±äÁ¿Öд洢ÁËÒ»¸ö¾ä±ú£¬Çë¼Çס´°¿ÚË𻵺ó¾ä±ú¾ÍʧЧÁË¡£ ÀýÈç GetActiveWindow º¯Êý¾Í¿ÉÒÔ·µ»Ø´°¿ÚµÄ¾ä±ú£¬ÕâÀïµÄ´°¿ÚÊÇÒ»¸öµ±Ç°»î¶¯µÄÓ¦ÓóÌÐò´°¿Ú¡£GetWindowText º¯Êý½ÓÊÜ´°¿ÚµÄ¾ä±ú£¬Èç¹û¸Ã´°¿ÚÓбêÌ⣬Ôò·µ»Ø±êÌâ¡£ÏÂÃæµÄ¹ý³ÌÓà GetActiveWindow ·µ»Ø»î¶¯´°¿ÚµÄ¾ä±ú£¬Óà GetWindowText ·µ»Ø¸Ã´°¿ÚµÄ±êÌ⣺ Declare Function GetActiveWindow Lib "user32" () As Long Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _ (ByVal Hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Function ActiveWindowCaption() As String Dim strCaption As String Dim lngLen As Long ' ´´½¨ÓÉ¿Õ×Ö·ûÌî³äµÄ×Ö·û´®¡£ strCaption = String$(255, vbNullChar) ' ·µ»Ø×Ö·û´®³¤¶È¡£ lngLen = Len(strCaption) ' µ÷Óà GetActiveWindow£¬·µ»Ø»î¶¯´°¿ÚµÄ¾ä±ú£¬ ' °Ñ¾ä±úÁ¬Í¬×Ö·û´®ºÍ×Ö·û´®³¤¶ÈÒ»Æ𴫵ݸø GetWindowText¡£ If (GetWindowText(GetActiveWindow, strCaption, lngLen) > 0) Then ' ·µ»Ø Windows дµ½×Ö·û´®ÖеÄÖµ¡£ ActiveWindowCaption = strCaption End If End Function GetWindowText º¯ÊýÓÐ 3 ¸ö²ÎÊý£º´°¿Ú¾ä±ú£»×¼±¸½ÓÊÜ´°¿Ú±êÌâµÄ NULL ½áÊø×Ö·û´®£»ÒÔ¼°¸Ã×Ö·û´®µÄ³¤¶È¡£
--------------------------------------------------------------------------------
Ïà¹ØÎÄÕÂ
ÆÊÎö Declare Óï¾ä 2004-1-28 15:08:06
ʲôÊÇ API£¿ 2004-1-28 15:01:53
¶Ô×¢²á±í²Ù×÷¼¼ÇÉ-½«³ÌÐòÔÚ¿ª»úʱÔËÐÐ 2003-11-18 9:24:59
officeXPÏÂʹÓÃÎļþ¶Ô»°¿òµÄÁíÍâÒ»ÖÖ·½·¨ 2003-11-17 8:47:04
ÕæÕýʵÏÖÔÚwindows2000ϹػúµÄÔ´´úÂë 2003-11-14 8:32:00
»ñÈ¡WindowsÓû§µÇ¼Ãû 2003-11-7 8:42:45
»ñÈ¡Íø¿¨ÎïÀíµØÖ· 2003-11-7 8:40:48
Òþ²ØAccessÖ÷´°¿ÚÖ®¶þ 2003-11-7 8:34:20
ÈçºÎÈô°Ìå×ÜÔÚ×îÇ°Ã棿 2003-11-7 8:25:19
ÈçºÎ¹Ø±Õ¼ÆËã»ú£¿ 2003-11-7 8:24:43
ÈçºÎ½¨Á¢¼òµ¥µÄ³¬¼¶Á¬½Ó£¿(ShellExecute) 2003-11-6 20:39:18
ÈçºÎÈô°ÌåµÄ±êÌâÌõÉÁ˸ÒÔÒýÆðÓû§×¢Ò⣿ 2003-11-6 20:38:43
ÔõÑùÕÒµ½Êó±êÖ¸ÕëµÄXY×ø±ê£¿ 2003-11-6 20:37:33
ÔÚ³ÌÐòÖÐÈçºÎ´ò¿ªºÍ¹Ø±Õ¹âÇýÃÅ£¿ 2003-11-6 20:20:00
ÔõÑùʹCtrl-Alt-DeleteÎÞЧ£¿ 2003-11-6 20:19:25
ÈçºÎÒƶ¯Ã»ÓбêÌâÀ¸µÄ´°¿Ú£¿ 2003-11-6 20:17:30
ÑÓʱº¯Êý 2003-11-6 20:16:53
Èÿؼþ×ÔÊÊÓ¦ÆÁÄ»·Ö±æÂÊ 2003-10-18 9:58:33
¼üÅ̳£ÓôúÂëÒ»ÀÀ±í 2003-10-17 19:54:02
ÖØж¨Î»Á´½Ó±í¶þ²½×ß 2003-10-17 19:00:07
ADOÁ¬½ÓÊý¾Ý¿â×Ö·û´®´óÈ« 2003-10-17 18:40:47
ÈçºÎÈ·¶¨µ±Ç°ÆÁÄ»·Ö±æÂÊ 2003-10-14 8:41:00
»ñÈ¡windows°²×°Â·¾¶ 2003-10-14 8:39:08
½« Microsoft Access ÓÃ×÷ Automation ·þÎñÆ÷ 2003-10-14 8:37:19
ÓÅ»¯Microsoft AccessÌá¸ßËÙ¶È 2003-10-6 10:31:55
|