wince C 開發 小技巧

2021-06-08 20:38:34 字數 1016 閱讀 6076

1、我們知道,在使用windows的開發機上用c#啟動乙個外部程式的方法有很多,但這些方法用在使用wince的目標工控機上都無能為力,現在小嫚儿以開啟乙個ie為例,介紹如何在wince下使用c#來開啟乙個外部檔案:首先新增命名空間

using system.runtime.interopservices;,然後呼叫api函式:

[dllimport("coredll.dll")]

private static extern int releasemutex(intptr hmutex);

[dllimport("coredll.dll")]

private static extern intptr createmutex(security_attributes lpmutexattributes,bool binitialowner,string lpname);

[dllimport("coredll.dll")]

public static extern void  setforegroundwindow(intptr hwnd);

然後使用下列**即可

intptr hdlg;

hdlg=findwindow(null, "視窗標題");

setforegroundwindow( hdlg );

最後,wince下的c#裡不支援groupbox控制項,建議使用panel控制項代替;不支援frame控制項,如果非要達到那樣的效果,可以用label和textbox組和起來應付一下。

其實,任何時候,只要.net framework無法滿足程式設計者的需要,通常都可以使用託管(interop)機制直接與windows 互動。大家也許看出呼叫原有的[dllimport("user32 .dll")]動態鏈結庫時無法滿足wince下程式要求,所以我們呼叫了[dllimport("coredll.dll")],並不是小嫚儿自己想到去呼叫它的,而是在網上看到了一篇「bitsbird」寫的例程,很多人將自己的經驗無私的與別人分享,所以小嫚儿寫了此篇文章,雖然讓行家看起來文章很淺顯,但希望能給象小嫚儿這樣的初學者提供一些捷徑。

Web開發小技巧

獲取客戶端ip public static string getclientip if null result result string.empty return result 獲取伺服器真實路徑 public static string getserverurl region 資料快取 獲取當前...

android開發小技巧

1.anr的log一般都在 data anr 目錄下,使用這個命令即可匯出log adb pull data anr traces.txt d 意思是將手機上的traces.txt匯出到電腦的d目錄下 2.開發的過程中經常需要看某個activity的類名,一種方法是通過hierarchy viewe...

Java開發小技巧

1 當我們提供介面的時候,ajax 返回的時候,當物件在轉換 json 序列化 的時候,值為null或者為 的字段還是輸出來了。看上去不優雅。如果專案裡有jackson include.include.always default 都參與序列化 include.non default 當value為...