導航:首頁 > 源碼編譯 > c取模塊句柄源碼

c取模塊句柄源碼

發布時間:2022-10-05 21:24:01

『壹』 c語言如何獲得當前運行的控制台程序的句柄

句柄(HANDLE)是WINDOWS環境下特有的窗口程序運行的識別號,而C語言是DOS環境下運行的代碼,在DOS環境下,沒有句柄的概念,理論上說,新時期環境下的新產物,不可能在舊環境下找到,就像要求達爾文用電子郵件給出版社發送文稿一樣荒誕不經,即使在控制台上運行的C程序可以通過WINDOWS任務管理器看到PID,但每次運行都不相同,那麼有如何使用呢?

『貳』 Linux下獲取進程打開的句柄數,用C代碼實現

可以通過指令查詢當前進程打開了多少句柄,Linux下有exec函數族可以執行指令,把指令寫進去就行了。
-查看當前進程打開了多少句柄數
# lsof -n|awk '{print $2}'|sort|uniq -c|sort -nr|more
-根據ID號來查看進程名。
# ps aef|grep ID號

『叄』 易語言 游戲基址=模塊dll+偏移量 應該怎麼才能讀取出來

你要先獲取模塊DLL的句柄

你可以網路下載一個 取模塊句柄的易語言模塊 後綴是.EC的

然後再易語言左邊的程序欄裡面————模塊引用表右鍵導入添加模塊引用,把你剛剛下載的模塊導入進去

然後寫一個格式類似這樣的

進程句柄 = 取模塊句柄 (「GGWAR3.dll」)

基址 = 內存_讀整數型 (進程ID, 進程句柄 + 十六到十 (「1C1160」))

模塊地址我已經打包好了pan.lanzou.com/i0unjvi 復制後瀏覽器打開就行

『肆』 C# 獲取其他窗體句柄

[DllImport("User32.dll", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string lpClassName,string lpWindowName);

[DllImport("user32.dll", EntryPoint = "FindWindowEx",SetLastError = true)]
private static extern IntPtr FindWindowEx(IntPtr hwndParent,IntPtr hwndChildAfter, stringlpszClass, string lpszWindow);

[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(IntPtr hWnd,int Msg, IntPtr wParam, string lParam);

const int WM_GETTEXT = 0x000D;
const int WM_SETTEXT = 0x000C;
const int WM_CLICK = 0x00F5;

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{

int retval = 0; //增加一個返回值用來判斷操作是否成功
//string lpszParentClass = "#32770"; //整個窗口的類名
string lpszParentWindow = "Form1"; //窗口標題
string lpszClass = "WindowsForms10.EDIT.app.0.b7ab7b"; //需要查找的子窗口的類名,也就是輸入框
//string lpszClass = "Edit";
string lpszClass_Submit = "WindowsForms10.BUTTON.app.0.b7ab7b"; //需要查找的Button的類名
//string lpszClass_Submit = "Button";
string lpszName_Submit = "確定"; //需要查找的Button的標題
string text = "";

IntPtr ParenthWnd = new IntPtr(0);
IntPtr EdithWnd = new IntPtr(0);

//查到窗體,得到整個窗體
ParenthWnd = FindWindow(null, lpszParentWindow);

//判斷這個窗體是否有效
if (!ParenthWnd.Equals(IntPtr.Zero))
{
//得到Form1這個子窗體的文本框,並設置其內容
EdithWnd = FindWindowEx(ParenthWnd, EdithWnd, lpszClass, ""); [color=#FF0000]這里獲取到的EdithWnd始終為0;[/color]

if (!EdithWnd.Equals(IntPtr.Zero))
{
text = "test1";
//調用SendMessage方法設置其內容
SendMessage(EdithWnd, WM_SETTEXT, IntPtr.Zero, text);
retval++;
}

//得到Button這個子窗體,並觸發它的Click事件
EdithWnd = FindWindowEx(ParenthWnd,
(IntPtr)0, lpszClass_Submit, lpszName_Submit);
if (!EdithWnd.Equals(IntPtr.Zero))
{
SendMessage(EdithWnd, WM_CLICK, (IntPtr)0, "0");
retval++;
}
}
}

『伍』 怎麼通過c語言 獲得 瀏覽器句柄啊

給你個例子

HWND GetDlgItem( int nID ) const;
Retrieves the specified child window.
GetDlgItem(ID)->GetWindowText(str)

『陸』 C語言中如何獲得當前進程句柄,謝謝!

DWORD PID;
PID = GetProcessPID(L"test.exe");
//獲取進程pid函數
DWORD GetProcessPID(LPCTSTR pName)
{
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (INVALID_HANDLE_VALUE == hSnapshot) {
return NULL;
}
PROCESSENTRY32 pe = { sizeof(pe) };
BOOL fOk;
for (fOk = Process32First(hSnapshot, &pe); fOk; fOk = Process32Next(hSnapshot, &pe)){
if (!_tcsicmp(pe.szExeFile, pName)) {
CloseHandle(hSnapshot);
return pe.th32ProcessID;
}
}
return NULL;
}
//由進程pid獲取進程句柄,置頂
HWND hh = GetProcessTopWindows(PID);
HWND GetProcessTopWindows(DWORD dwPID){
count = 0;
EnumWindows((WNDENUMPROC)EnumWndProc, (LPARAM)dwPID);
if(count > 0) {
//cout << "窗口句柄是:" << nhWnd[count -1] << endl;//輸出句柄,可用spy++工具核對
return (nhWnd[count -1]);
}
return NULL;
}
別忘了添加對應頭文件。

『柒』 在C#中如何獲取dll的句柄並調用dll中的方法

無法在DLL"HKPlugIn.dll"中找到名為"connectDVR"的入口
說明你的這個dll里沒有connectDVR這個公共方法
你檢查一下是不是大小寫錯了?或者不能被外部訪問?

首先要DllImport,例如:
[DllImport(@"E:\DLL\abc.dll", EntryPoint = "調用方法名")]
protected static extern 方法返回類型 調用方法名(參數列表);

然後就可以在你的代碼里使用這個方法了

比如:
[DllImport(@"E:\DLL\ExGif.dll", EntryPoint = "CheckGif")]
protected static extern bool CheckGif(string filename);

調用:
if(CheckGif("c:\\a.gif")){

}

『捌』 C#怎樣獲得窗口句柄

一個網上的例子
c# 獲取滑鼠處窗口句柄,程序嵌入桌面

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

[DllImport("user32.dll", EntryPoint = "FindWindow")]
public static extern int FindWindow(
string lpClassName,
string lpWindowName
);

[DllImport("user32.dll", EntryPoint = "GetWindow")]//獲取窗體句柄,hwnd為源窗口句柄
/*wCmd指定結果窗口與源窗口的關系,它們建立在下述常數基礎上:
GW_CHILD
尋找源窗口的第一個子窗口
GW_HWNDFIRST
為一個源子窗口尋找第一個兄弟(同級)窗口,或尋找第一個頂級窗口
GW_HWNDLAST
為一個源子窗口尋找最後一個兄弟(同級)窗口,或尋找最後一個頂級窗口
GW_HWNDNEXT
為源窗口尋找下一個兄弟窗口
GW_HWNDPREV
為源窗口尋找前一個兄弟窗口
GW_OWNER
尋找窗口的所有者
*/
public static extern int GetWindow(
int hwnd,
int wCmd
);

[DllImport("user32.dll", EntryPoint = "SetParent")]//設置父窗體
public static extern int SetParent(
int hWndChild,
int hWndNewParent
);

[DllImport("user32.dll", EntryPoint = "GetCursorPos")]//獲取滑鼠坐標
public static extern int GetCursorPos(
ref POINTAPI lpPoint
);

[StructLayout(LayoutKind.Sequential)]//定義與API相兼容結構體,實際上是一種內存轉換
public struct POINTAPI
{
public int X;
public int Y;
}

[DllImport("user32.dll", EntryPoint = "WindowFromPoint")]//指定坐標處窗體句柄
public static extern int WindowFromPoint(
int xPoint,
int yPoint
);

private void timer1_Tick(object sender, EventArgs e)
{
POINTAPI point = new POINTAPI();//必須用與之相兼容的結構體,類也可以

GetCursorPos(ref point);//獲取當前滑鼠坐標
int hwnd = WindowFromPoint(point.X, point.Y);//獲取指定坐標處窗口的句柄

this.label1.Text =point.X.ToString() + ":" + point.Y.ToString() + "-" + hwnd.ToString();//顯示效果,此時窗口已經嵌入桌面了
}

const int GW_CHILD = 5;//定義窗體關系
private void Form1_Load(object sender, EventArgs e)
{
int hDesktop = FindWindow("Progman", null);//獲取系統句柄
hDesktop = GetWindow(hDesktop, GW_CHILD);//獲取其子窗口句柄,就是桌面的句柄
SetParent((int)this.Handle, hDesktop);//設置父窗體,第一個為要被設置的窗口,第二個參數為指定其父窗口句柄
}
}
}

閱讀全文

與c取模塊句柄源碼相關的資料

熱點內容
天津水游城電影院今日影訊簡介 瀏覽:98
lin運演算法則 瀏覽:574
天刀命令 瀏覽:132
韓國電影在閣樓偷窺女主的 瀏覽:417
葉天明與柳韻小說 瀏覽:517
優盤加密文件和投屏沖突 瀏覽:537
韓國推理電影免費在線觀看 瀏覽:646
php修改資料庫欄位 瀏覽:431
老司機看片入口 瀏覽:890
梁山正信樓電影院買票入口 瀏覽:59
消失的眼角膜未刪減版 瀏覽:196
目前安卓平板什麼處理器最好 瀏覽:528
中考幫pdf 瀏覽:678
愛搞影視網站 瀏覽:566
我要片子的網站 瀏覽:501
androidx軸y軸 瀏覽:556
簡愛演員表英國1970 瀏覽:698
我在電影院給他了會不會被拍到 瀏覽:480
校園兩個女生同性戀電影 瀏覽:17
三菱應用基礎與編程入門 瀏覽:68