C 平台互操作大全

2021-05-22 17:09:06 字數 2477 閱讀 7702

新增引用using system.runtime.interopservices;

[dllimport("user32.dll", charset = charset.unicode)]//windows

[dllimport("coredll.dll", charset = charset.unicode)]//mobile

public static extern intptr postmessage(intptr hwnd, int wmsg, intptr wparam, intptr lparam);

[dllimport("user32.dll")]

[dllimport("coredll.dll")]

public static extern intptr findwindow(string lpclassname, string lpwindowname);

[dllimport("user32.dll")]

[dllimport("coredll.dll")]

public static extern intptr findwindowex(intptr hwndparent, intptr hwndchildafter, string lpszclass, string lpszwindow);

[dllimport("coredll.dll", setlasterror=true)]

public static extern int setwindowlong(intptr hwnd, int nindex, int dwnewlong);

[dllimport("coredll.dll", setlasterror = true)]

public static extern int setwindowlong(intptr hwnd, int nindex, wndprocdelegate newproc);

[dllimport("coredll.dll", setlasterror = true)]

public static extern intptr getwindowlong(intptr hwnd, int nindex);

[dllimport("coredll.dll")]

public static extern intptr createwindowex(uint dwexstyle, string lpclassname,string lpwindowname, uint dwstyle, int x, int y, int nwidth, int nheight,intptr hwndparent, intptr hmenu, intptr hinstance, intptr lpparam);

[dllimport("coredll.dll")]

public static extern intptr callwindowproc(intptr lpprevwndfunc, intptr hwnd, uint msg, intptr wparam, intptr lparam);

[dllimport("coredll.dll", charset = charset.auto)]

public static extern intptr defwindowproc(intptr hwnd, int msg, intptr wparam, intptr lparam);

[dllimport("coredll.dll", charset = charset.auto)]

public static extern intptr getmodulehandle(string modname);

[dllimport("coredll.dll", charset = charset.auto)]

public static extern bool destroywindow(intptr hwnd);

[dllimport("coredll.dll")]

private static extern int setwindowshookex(int type, hookkeyproc hookkeyproc, intptr hinstance, int m);

[dllimport("coredll.dll")]

private static extern int callnexthookex(hookkeyproc hhk,int ncode,intptr wparam,intptr lparam);

[dllimport("coredll.dll", setlasterror = true)]

private static extern int unhookwindowshookex(int idhook);

[dllimport("coredll.dll")]

private static extern intptr getmodulehandle(string mod);

[dllimport("coredll.dll")]

private static extern int getcurrentthreadid();

C 互操作性

互操作性使您能夠保留和利用在現有非託管 中的投入。託管 執行在公共語言執行庫 clr 的控制之下的 非託管 執行在 clr 之外的 稱為 非託管 com com c 元件 activex 元件 和 win32 api 都是非託管 的示例。為什麼要使用互操作性呢?net 是建立在作業系統的之上的乙個開...

C 嵌入互操作型別

嵌入互操作型別 embed interop types 運用office程式設計呼叫excel 的pia時microsoft.office.interop.excel.dll時會產生如下問題 1.提示錯誤 未能載入檔案或程式集 microsoft.office.interop.excel.dll 2...

彙編與C互操作

彙編與c互操作 c語言內嵌彙編 c語言呼叫彙編過程 彙編呼叫c語言過程 1 開啟vs2008,建立乙個vc 空工程。2 在solution explorer上右擊工程名,選擇custom build rules 在彈出的對話方塊上勾選microsoft macro assembler。3 在solu...