getcurrentdirectory只是返回當前程序的當前目錄,而並不是程序的映象檔案(.exe)所在的目錄
getcurrentdirectory()適用於xp等系統,在wince上不能使用
getmodulefilename()適用於wince2.0以後
使用方法:
//下面的一段**主要是獲得當前程式的執行目錄(.exe)所在的目錄
getmodulefilename函式
winapi dword getmodulefilename(hmodule hmodule
,lpwstr lpfilename
, dword nsize
);getbuffer和releasebuffer是一套需要配合使用的函式, 與getbuffersetlength相比, 優點是如果分配的空間大於實際儲存的字串(0結尾),
releasebuffer會把多餘申請的空間釋放, 歸還給系統; 但使用時需要注意以下問題: 如果要儲存的字串為abc(0結尾),則getbuffer引數應至少
為3; 如果要儲存的內容不是以0結尾, 比如是讀取檔案資料, 則getbuffer引數如果大於檔案長度時,
releasebuffer引數一定要為檔案長度
(如果getbuffer引數為檔案長度的話不存在問題,releasebuffer引數可以為預設-1)!
getbuffersetlength相對比較容易理解, 它申請乙個指定長度的空間, 即使裡面最終儲存的字串長度小於申請的空間長度, 也不會將
多餘空間釋放.
本文** http://blog.chinaunix.net/u2/61062/showart_1892515.html
獲取當前檔案路徑。
之前搞模組載入,苦於無法獲取當前檔案路徑,檔名 後來沒通過獲取當前檔案路徑,檔名,給搞定了。結果今天把這個問題也解決了,做個記錄 file zhus err.js varcursrc newfunction catch e console.log cursrc zhus err 以上編碼,只適用於f...
獲取當前檔案的路徑
一 獲取當前檔案的路徑 1.system.diagnostics.process.getcurrentprocess mainmodule.filename 獲取模組的完整路徑,包括檔名。2.system.environment.currentdirectory 獲取和設定當前目錄 該程序從中啟動的...
獲取當前檔案路徑 當前工作目錄路徑
import os current dir os.path.abspath os.path.dirname file 當前檔案下的絕對路徑 print current dir 輸出 e weidian lc requestinfo current dir1 os.path.dirname file ...