| | |
Is this possible? Is there a better approach?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2004
Posts: 2
Reputation:
Solved Threads: 0
Hi all,
First off, I'm relatively new to the world of C/C++. I've taken some courses in University years ago and haven't used it much since.
What brings me back is the following dilema I have:
I've built an application using National Instruments LabVIEW (www.ni.com). For those not familiar its a graphical programming language used mostly for customized data acquisition and control applications. A requirement of software built with LabVIEW is that it requires the LabVIEW runtime engine. It comes packed as an installer and it must be installed before the labview created exe can run.
What we'd like to do is put this application on a cd and have it autorun when the user inserts the cd. This works fine if they have the run time engine installed but won't work if its not installed.
So what I was thinking is:
autorun a C created program to detect if the runtime engine is installed (I would have to check for a registry key)
- If it is installed, run my exe
- If not installed, run runtime engine setup,the my exe
Is this hard to do? Anyone tried something like this before? Is this something installshield is designed for? How can I detect if a registry key exists?
Thanks for any help you can provide.
Jay
First off, I'm relatively new to the world of C/C++. I've taken some courses in University years ago and haven't used it much since.
What brings me back is the following dilema I have:
I've built an application using National Instruments LabVIEW (www.ni.com). For those not familiar its a graphical programming language used mostly for customized data acquisition and control applications. A requirement of software built with LabVIEW is that it requires the LabVIEW runtime engine. It comes packed as an installer and it must be installed before the labview created exe can run.
What we'd like to do is put this application on a cd and have it autorun when the user inserts the cd. This works fine if they have the run time engine installed but won't work if its not installed.
So what I was thinking is:
autorun a C created program to detect if the runtime engine is installed (I would have to check for a registry key)
- If it is installed, run my exe
- If not installed, run runtime engine setup,the my exe
Is this hard to do? Anyone tried something like this before? Is this something installshield is designed for? How can I detect if a registry key exists?
Thanks for any help you can provide.
Jay
Greetings lvdude,
Doing this is not hard. There is a simple approach to this.
Understanding that you are talking about Windows, hence the "Registry", it is not hard to check for a key and its existance.
I just wrote an example of how to query a registry key. It may help gear you in the right direction: Hope this helps.
RegQueryValueEx()
The RegQueryValueEx function retrieves the type and data for a specified value name associated with an open registry key. Or learn more about it here.
There are other functions, though simply doing an MSDN search may pull up further documentation on such functions within the windows header file.
I hope this does help, and if you have any further questions please feel free to ask.
- Stack Overflow
Doing this is not hard. There is a simple approach to this.
Understanding that you are talking about Windows, hence the "Registry", it is not hard to check for a key and its existance.
I just wrote an example of how to query a registry key. It may help gear you in the right direction:
#include <windows.h> #include <stdio.h> int checkKey(HKEY tree, const char *folder, char *key) { long lRet; HKEY hKey; char temp[150]; DWORD dwBufLen; // Open location lRet = RegOpenKeyEx( tree, folder, 0, KEY_QUERY_VALUE, &hKey ); if (lRet != ERROR_SUCCESS) return 0; // Get key dwBufLen = sizeof(temp); lRet = RegQueryValueEx( hKey, key, NULL, NULL, (BYTE*)&temp, &dwBufLen ); if (lRet != ERROR_SUCCESS) return 0; printf("Key value: %s\n", temp); // Close key lRet = RegCloseKey( hKey ); if (lRet != ERROR_SUCCESS) return 0; // Got this far, then key exists return 1; } int main() { printf("Checking for key: HKEY_CURRENT_USER -> Control Panel -> Desktop -> Wallpaper\n"); if (checkKey(HKEY_CURRENT_USER, "Control Panel\\Desktop", "Wallpaper")) printf("Key Exists.\n"); else printf("Key Does Not Exist.\n"); return 0; }
RegQueryValueEx()
The RegQueryValueEx function retrieves the type and data for a specified value name associated with an open registry key.
LONG RegQueryValueEx(
HKEY hKey, // handle of key to query
LPTSTR lpValueName, // address of name of value to query
LPDWORD lpReserved, // reserved
LPDWORD lpType, // address of buffer for value type
LPBYTE lpData, // address of data buffer
LPDWORD lpcbData // address of data buffer size
);There are other functions, though simply doing an MSDN search may pull up further documentation on such functions within the windows header file.
I hope this does help, and if you have any further questions please feel free to ask.
- Stack Overflow
Following the rules will ensure you get a prompt answer to your question. If posting code, please include BB [code][/code] tags. Your question may have been asked before, try the search facility.
IRC
Channel: irc.daniweb.com
Room: #c, #shell
IRC
Channel: irc.daniweb.com
Room: #c, #shell
•
•
Join Date: Oct 2004
Posts: 2
Reputation:
Solved Threads: 0
Thanks for the excellent post, I'm sure that will save me allot of time.
I'm in the process of setting up a c++ compiler and re-acquainting myself, then I'll try to get your example working.
One more simple question: How do you run an exe from a C program? I'm thinking theres probably a OPEN or RUN command or such?
BTW, I did a quick search on MSDN to try to find such a function, but didn't get anything helpful. Is there an easy way to look functions up?
Thanks again
I'm in the process of setting up a c++ compiler and re-acquainting myself, then I'll try to get your example working.
One more simple question: How do you run an exe from a C program? I'm thinking theres probably a OPEN or RUN command or such?
BTW, I did a quick search on MSDN to try to find such a function, but didn't get anything helpful. Is there an easy way to look functions up?
Thanks again
![]() |
Similar Threads
- An alternative approach? (C++)
- Has any one used extremetable? (JavaScript / DHTML / AJAX)
- Alternative approach to frames....? (Site Layout and Usability)
- Unusual SW Development Approach (IT Professionals' Lounge)
- how to approach a good quality complaint form (HTML and CSS)
- learning php (PHP)
- ITZoom: Changed design and a new approach... (Website Reviews)
- The best approach to advertising for my site? (Advertising Sales Strategies)
Other Threads in the C++ Forum
- Previous Thread: Cube Root
- Next Thread: dynamic polymorphish in c++
| Thread Tools | Search this Thread |
api array based beginner bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion count database delete deploy desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number output parameter pointer problem program programming project python random read recursion recursive return sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





