By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,863 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

need to get a path/folder name from the registry

P: 3
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?
Sep 21 '07 #1
Share this Question
Share on Google+
1 Reply


kadghar
Expert 100+
P: 1,295
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:

Expand|Select|Wrap|Line Numbers
  1. dim Lon1 as long
  2. dim Sttr1 as string
  3. 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

Expand|Select|Wrap|Line Numbers
  1. str1 = left(str1,instr(str1,chr(0))-1)
Sep 21 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.