473,408 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

need to get a path/folder name from the registry

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
1 1549
kadghar
1,295 Expert 1GB
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

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

Similar topics

0
by: AlieN | last post by:
I have a standard installation procedure for a service that I wrote. A user that installs it can choose the installation folder. BUT, when the installation is done, together with exe and dll,...
1
by: Locke Nash Cole | last post by:
I'm making a utility similar to MSConfig, I've found it easy enough to obtain the startup items from the registry for the current user and local machine... but what about the Startup folder on the...
0
by: Andrzej Lipski | last post by:
Hello I am developing a Windows Ce 5.0 mobile application. I followed the example shown at : Creating Self-Updating Applications With the .NET Compact Framework...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.