I have been making an .exe to empty the OLK folder created by outlook
at the minute the folder location is hard written into the code
e.g C:\Documents And Settings\Luke\Local Settings
Is it possible to create a string variable and assign it the path based on a registry key so it would work on any pc not just on mine with my login?
the folder name and path can be obtained from HKEY-CURRENT-USER\Software\Microsoft....
how is this achievable?
This function will give you the current user name
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
now just declare a long to call, and a string to save it:
- dim Lon1 as long
-
dim Sttr1 as string
-
Lon1 = getusername(str1, 20)
The second parameter is the lenght of the user name, if the lenght is shorter than what you put, it will fill the rest with Chr(0)
Lets say the user name is Luke then str1 = luke and 16 chr(0)'s
you can remove them with
- str1 = left(str1,instr(str1,chr(0))-1)