rng
asked on
GetSystemDirectory .
Here is a portion of my program.
'Declarations
Public Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Dim l as long, strDir as string
l = GetSystemDirectory(strDir, 20)
I want to use GetSystemDirectory to find the path to the system directory. However, it return 0 (0 means function call fail). I don't know why ? Is my program code wrong ?
Does any other function do the same?? I want to find a path to the system directory.
Please help.
Regards,
Raymond
'Declarations
Public Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Dim l as long, strDir as string
l = GetSystemDirectory(strDir,
I want to use GetSystemDirectory to find the path to the system directory. However, it return 0 (0 means function call fail). I don't know why ? Is my program code wrong ?
Does any other function do the same?? I want to find a path to the system directory.
Please help.
Regards,
Raymond
This should solve your problem...
http://www.ozemail.com.au/~measlea/api/sysdir.htm
http://www.ozemail.com.au/~measlea/api/sysdir.htm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Private Sub Command1_Click()
Dim lRet As Long
Dim sBuffer As String
sBuffer = String(260, Chr(0))
lRet = GetSystemDirectory(sBuffer , 260)
sBuffer = Left(sBuffer, lRet)
Debug.Print sBuffer
End Sub
Dim lRet As Long
Dim sBuffer As String
sBuffer = String(260, Chr(0))
lRet = GetSystemDirectory(sBuffer
sBuffer = Left(sBuffer, lRet)
Debug.Print sBuffer
End Sub
From http://members.tripod.com/cuinl/Tips/systemdir.htm
'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Insert this code to the module :
Declare Function GetSystemDirectory Lib "kernel32" Alias _
"GetSystemDirectoryA" (ByVal lpBuffer As String, _
ByVal nSize As Long) As Long
'Insert this code to your form:
Private Sub Form_Load()
Dim S As String
S = String(80, 0)
Call GetSystemDirectory(S, 80)
UserName = Left(S, InStr(S, Chr(0)) - 1)
MsgBox (S)
End Sub
'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Insert this code to the module :
Declare Function GetSystemDirectory Lib "kernel32" Alias _
"GetSystemDirectoryA" (ByVal lpBuffer As String, _
ByVal nSize As Long) As Long
'Insert this code to your form:
Private Sub Form_Load()
Dim S As String
S = String(80, 0)
Call GetSystemDirectory(S, 80)
UserName = Left(S, InStr(S, Chr(0)) - 1)
MsgBox (S)
End Sub
ASKER
Thank you very much.
http://www.vbcity.com/page.asp?f=howto&p=system_sysdir
http://www.vbgreatone.8m.com/VB/g/getsystemdirectory.htm
http://www.vb2themax.com/Item.asp?PageID=TipBank&ID=132