冰楓論壇

 找回密碼
 立即註冊
ads_sugarbook
搜索
查看: 1399|回覆: 0
打印 上一主題 下一主題

[開源] 【VB.NET】拖拉圖示讀取PID

[複製鏈接]

57

主題

1

好友

252

積分

中級會員

Rank: 3Rank: 3

UID
240679
帖子
286
主題
57
精華
0
積分
252
楓幣
284
威望
250
存款
382
贊助金額
0
推廣
0
GP
72
閱讀權限
30
在線時間
47 小時
註冊時間
2018-7-14
最後登入
2023-9-8

Android勳章 私服達人 懶人勳章 太陽勳章 幼兒勳章 性別(女) 性別(男) 音樂勳章 神手勳章 積分勳章 發帖達人 2020年紀念勳章

跳轉到指定樓層
1
發表於 2019-11-12 00:29:04 |只看該作者 |倒序瀏覽
本帖最後由 Beebong 於 2019-11-12 00:45 編輯

小弟獻醜,大佬見笑了。

需要物件:PictureBox(Iamge記得放圖) *1 、Label *1
方案專案->專案->Resources 記得放.ico
1.JPG

Module:
Public Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Integer, ByVal yPoint As Integer) As IntPtr
Public Declare Function
GetWindowThreadProcessId Lib "user32" (ByVal hwnd As UInteger, ByRef lpdwProcessId As IntPtr) As IntPtr
Dim PhandleA As IntPtr
Public Structure POSSITION
    Dim X As Single
    Dim
Y As Single
End Structure
Public Function
WindowPointXY(ByVal xPoint As UInteger, ByVal yPoint As UInteger) As UInteger
    Dim hwnd As UInteger
    Dim
PidPoint As UInteger
   
hwnd = WindowFromPoint(xPoint, yPoint)
    GetWindowThreadProcessId(
hwnd, PidPoint)
    Return
PidPoint
End Function
Form:
Private Sub PictureBox1_MouseDown(sender As Object, e As System.windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
        PictureBox1.Cursor = New Cursor(New Bitmap(My.Resources.Bee).GetHicon())
        PictureBox1.Image = Nothing
End Sub
Private Sub PictureBox1_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
        Phandle = WindowPointXY((Windows.Forms.Cursor.Position.X), (Windows.Forms.Cursor.Position.Y))
        PictureBox1.Image = My.Resources.Bee
       PictureBox1.Cursor = Cursors.Arrow
       Label1.Text = "讀取到的進程名稱:" & Process.GetProcessById(Phandle).ProcessName
End Sub

如果執行上有問題請回覆告知,我是直接把以前寫的專案片段Code貼上來
[發帖際遇]: Beebong 為了呼吸乾淨的空氣,向盧太太購買「谷關空氣瓶」,花費 1 楓幣 幸運榜 / 衰神榜
收藏收藏0 推0 噓0


把本文推薦給朋友或其他網站上,每次被點擊增加您在本站積分: 1骰子
複製連結並發給好友,以賺取推廣點數
簡單兩步驟,註冊、分享網址,即可獲得獎勵! 一起推廣文章換商品、賺$$
高級模式
B Color Image Link Quote Code Smilies |上傳

廣告刊登意見回饋關於我們職位招聘本站規範DMCA隱私權政策

Copyright © 2011-2024 冰楓論壇, All rights reserved

免責聲明:本網站是以即時上載留言的方式運作,本站對所有留言的真實性、完整性及立場等,不負任何法律責任。

而一切留言之言論只代表留言者個人意見,並非本網站之立場,用戶不應信賴內容,並應自行判斷內容之真實性。

小黑屋|手機版|冰楓論壇

GMT+8, 2024-5-3 00:40

回頂部