計算機二級VB:獲取系統和Windows目錄
儅我們需要讓自己的程序判斷系統目錄和windows目錄的名稱時。您可以調用windowsapi函數getsystemdirectory和getwindowsdirectory。
聲明:
獲取系統目錄
下麪是引用的片段:
public declare function getsystemdirectory lib ' kernel 32 ' alias ' getsystemdirectorya ' _
(byval LP buffer爲string,byval nsize爲long)爲long。
'獲取windows目錄
下麪是加引號的片段:
declare function getwindows directory lib ' kernel 32 ' alias ' getwindows directory ya ' _
(byval LP buffer爲string,byval nsize爲long)爲long。
致電:
檢查系統目錄。
下麪是引用的片段:
public function get system path()as string
dimp as string * 80
dim length as string
length = get system directory(p,len(p))
path = left(p,length)
get system path = path
end function
'檢查windows目錄。
下麪是引用的片段:
public function getwindowspath()as string
dim p as string * 80
dim length as long
dim path as string
length = getwindows directory(p,len(p))
path = left(p,length)
getwindowspath = path
end function
0條評論