Solved

Help!

Posted on 1998-02-17
17
237 Views
Last Modified: 2010-08-05
I am currently using the ShellExecute command to run applications from within my application.  Like this...

ShellExecute(NULL, "open", "Application.exe",NULL, NULL, SW_SHOWNORMAL);

Well I need to tell my program where the other program (which is being launched form my app) is located.  I have been thinking and feal that using a reg key (which will be filed out when my setup application runs) tell it the directory that the file will be in.  How would I do that??  The reg key that will be used is...
HKEY_CURRENT_USER\High Voltage R&D\webmaster\install_dir

thanks
0
Comment
Question by:4099aol
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 8
17 Comments
 
LVL 3

Accepted Solution

by:
q2guo earned 20 total points
ID: 1182430
What you should do is create a text file with extension .reg containing the two lines below

REGEDIT4
HKEY_CURRENT_USER\High Voltage R&D\webmaster\install_dir

and inside you program call 'regedit file.reg'

0
 
LVL 32

Expert Comment

by:jhance
ID: 1182431
I'd suggest that you use the RegCreateKeyEx and RegQueryValueEx() API functions instead.
0
 

Author Comment

by:4099aol
ID: 1182432
do not understand your answer and do not uderstand your comment.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:q2guo
ID: 1182433
Ok, you can either do what I suggested.  Or go with jhance.

Call RegCreateKeyEx
here is how to call it

PHKEY pkey;
LPDWORD lpdword;
RegCreateKeyEx(HKEY_CURRENT_USER, NULL, 0,
               "High Voltage R\&D\\webmaster\\install_dir" ,
               REG_OPTION_NON_VOLATILE,
               KEY_ALL_ACCESS, &pkey, &lpdword);

0
 

Author Comment

by:4099aol
ID: 1182434
ok this

PHKEY pkey;
LPDWORD lpdword;
RegCreateKeyEx(HKEY_CURRENT_USER, NULL, 0, "High Voltage R\&D\\webmaster\\install_dir" , REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, &pkey, &lpdword);

would tell me what the value of the key is?? or will it run the application???
0
 
LVL 3

Expert Comment

by:q2guo
ID: 1182435
RegCreateKeyEx will create a key with no value
You call RegSetValue to set the value of the key

PHKEY pkey;
LPDWORD lpdword;
Char *keyvalue[] = "what ever";
RegCreateKeyEx(HKEY_CURRENT_USER, NULL, 0, "High Voltage R\&D\\webmaster\\install_dir" ,                       REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, &pkey, &lpdword);
RegOpenKey(HKEY_CURRENT_USER, NULL, &pkey);
RegSetValue(HKEY_CURRENT_USER, NULL, REG_SZ, keyvalue, 10);

the value 10 comes from the size in byte of the string - keyvalue.

0
 

Author Comment

by:4099aol
ID: 1182436
so this will create a blank reg key correct??

PHKEY pkey;
LPDWORD lpdword;
RegCreateKeyEx(HKEY_CURRENT_USER, NULL, 0, "High Voltage R\&D\\webmaster\\install_dir" , REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, &pkey, &lpdword);

and this will give it the value of "what ever"??

PHKEY pkey;
LPDWORD lpdword;
Char *keyvalue[] = "what ever";
RegCreateKeyEx(HKEY_CURRENT_USER, NULL, 0, "High Voltage
R\&D\\webmaster\\install_dir" , REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, &pkey, &lpdword);
RegOpenKey(HKEY_CURRENT_USER, NULL, &pkey);RegSetValue(HKEY_CURRENT_USER, NULL, REG_SZ, keyvalue, 10);
0
 
LVL 3

Expert Comment

by:q2guo
ID: 1182437
Ok, you got the create a blank key part correct

but, to give a key a value

you don't need the line RegCreateKeyEx(....)

Other than this, you got it
0
 

Author Comment

by:4099aol
ID: 1182438
so this will create the key and put the value in it?

PHKEY pkey;
LPDWORD lpdword;
Char *keyvalue[] = "what ever";
RegCreateKeyEx(HKEY_CURRENT_USER, NULL, 0, "High Voltage R\&D\\webmaster\\install_dir" , REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, &pkey, &lpdword); RegOpenKey(HKEY_CURRENT_USER, NULL, &pkey);RegSetValue(HKEY_CURRENT_USER, NULL, REG_SZ, keyvalue,10);
0
 
LVL 3

Expert Comment

by:q2guo
ID: 1182439
yeap
0
 

Author Comment

by:4099aol
ID: 1182440
please check the codes (which I just posted) I am reciving about 25-40 error messages.  I am using Borland C++ Builder v1.0
0
 
LVL 3

Expert Comment

by:q2guo
ID: 1182441
Can you put in above code line by line?
for example, put in
PHKEY pkey;
then compile, if it compiles fine
then put in the next line in

The codes works fine under visual C++

0
 

Author Comment

by:4099aol
ID: 1182442
Ok a { needs to be put somewhere in the third line...
0
 
LVL 3

Expert Comment

by:q2guo
ID: 1182443
oh, the third line should be
char keyvalue[] = "what ever";

* should not be in front of keyvalue
0
 

Author Comment

by:4099aol
ID: 1182444
There are a ton of errors!!! Starting with line four...
0
 
LVL 3

Expert Comment

by:q2guo
ID: 1182445
Probably Borland builder does not have the command
RegCreateKeyEx
why don't you reject my answer, so that this question is open again.
0
 

Author Comment

by:4099aol
ID: 1182446
I will give u the credit for all of this time you spent.  I also need to change the question around a bit.


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question