Hi,
I posted a question on the VB Gen. questions board that has a question on C++ stuff in it.
Could you please take a look.
Thanks,
JazzBass
http://forums.vb-world.net/showthrea...threadid=60650
Printable View
Hi,
I posted a question on the VB Gen. questions board that has a question on C++ stuff in it.
Could you please take a look.
Thanks,
JazzBass
http://forums.vb-world.net/showthrea...threadid=60650
Well your function is only able to return a true or a false. So if you want you function to fail if the version is not 2.5 then:
PHP Code:BOOL IsMDACPresent()
{
BOOL bRetVal = FALSE;
TCHAR szMDACRegKey[] = TEXT("Software\\Microsoft\\DataAccess");
TCHAR szValue[MAX_PATH];
DWORD dwValue = 0;
HKEY hKLM = NULL;
LONG lReg = 0;
LONG ldwReg = 0;
LONG lszReg = 0;
DWORD dwKeySize = 0;
char* pos;
if((g_dwOSVerFlags & dwWin2K) == dwWin2K)
{
return TRUE;
}
lReg = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
szMDACRegKey,
0,
KEY_READ,
&hKLM);
if(ERROR_SUCCESS == lReg)
{
dwKeySize = sizeof(szValue)/sizeof(TCHAR);
lszReg = RegQueryValueEx(hKLM, TEXT("FullInstallVer"), NULL, NULL, (BYTE*) szValue, &dwKeySize);
ldwReg = RegQueryValueEx(hKLM, TEXT("Full21Install"), NULL, NULL, (BYTE*) dwValue, &dwKeySize);
if((ERROR_SUCCESS == lszReg) || (ERROR_SUCCESS == ldwReg))
{
pos = strstr(szValue,"2.5");
if(pos)
{
RegCloseKey(hKLM);
return TRUE;
}
else
return FALSE;
}
else
{
RegCloseKey(hKLM);
return FALSE;
}
}
else
{
return FALSE;
}
}
Technocrat,
Thank you so very much. I appreciate your help. You da man. I know it's rather simple, but given I really don't have any background in C, it's pretty hard.
I really wish Microsoft was a little better at explaining stuff like this. They tell you you need to modify the code, but don't always give examples.
A million thanks! I'll recompile the exe and give it a shot.
BTW, I've been doing some research and it looks like I need to add the string.h header file to the cpp file. Is this correct?
JazzBass
No problem.
Microsoft is really bad at explaining anything program wise.
Yeah you will most likely have to had string.h if it is not already in the cpp file.
Technocrat,
I hear ya. Another quick question.
I've come up with some modifed code that lets me check to see if the user has 2.5 or greater. Could you please double check it for me before I go home and try?
Thanks,
I've included <stdlib.h> at the top of the cpp file.
Thank you very much.Code:
BOOL IsMDACPresent()
{
BOOL bRetVal = FALSE;
TCHAR szMDACRegKey[] = TEXT("Software\\Microsoft\\DataAccess");
TCHAR szValue[MAX_PATH];
DWORD dwValue = 0;
HKEY hKLM = NULL;
LONG lReg = 0;
LONG ldwReg = 0;
LONG lszReg = 0;
INT intNeedVersion = 2.5;
INT intCurrentVersion
DWORD dwKeySize = 0;
if((g_dwOSVerFlags & dwWin2K) == dwWin2K)
{
return TRUE;
}
lReg = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
szMDACRegKey,
0,
KEY_READ,
&hKLM);
if(ERROR_SUCCESS == lReg)
{
dwKeySize = sizeof(szValue)/sizeof(TCHAR);
lszReg = RegQueryValueEx(hKLM, TEXT("FullInstallVer"), NULL, NULL, (BYTE*) szValue, &dwKeySize);
ldwReg = RegQueryValueEx(hKLM, TEXT("Full21Install"), NULL, NULL, (BYTE*) dwValue, &dwKeySize);
if((ERROR_SUCCESS == lszReg) || (ERROR_SUCCESS == ldwReg))
{
// Lines that I added to check for 2.5 or greater
intCurrentVersion = atoi(szValue); //Change version into integer to compare
if (intCurrentVersion >= intNeedVersion)
{
RegCloseKey(hKLM);
return TRUE;
}
else
return FALSE;
}
else
{
RegCloseKey(hKLM);
return FALSE;
}
}
else
{
return FALSE;
}
}
JazzBass
Hmm I dont know about this. I deleted the sample I was working with so I can test this my self right now. The problem I see is that you are converting it to a number, but the version number in the reg is like 2.502.2322. So I dont know what problem having 2 decimal points will do to your final number. Hopefully it will just round it. But I am a little unsure.
Nope it does not work with yours because you are using ints, so it rounds to the whole #. Change to this:
PHP Code:double dblNeedVersion = 2.5;
double dblCurrentVersion;
dblCurrentVersion = atof(szValue);
if (dblCurrentVersion >= dblNeedVersion)
Yeah it works if you make the changes just like I said in my second post, I did test it and it works.
I dont really understand your other question:
I just tried converting a number like that in VB to a long and an int and it looks like it won't work.
Do you have any other ideas how to get this done?
Are you asking me a different question about number type conversions in VB?
You responded a bit quicker than me and so that last post was after your test results.
Disregard that. Bad timing.
I just said that I tested changing a string to a long and it gave me a error 13 - type mismatch.
There must be a difference in how VB and C++ handles that. I just told it convert a number (2.50.4403.12) I put in a text box to a long and it errored out. That's all.
Well, great! I'll go ahead and recompile tonight and hopefully it will work.
Thanks again and sorry for the confusion.
JazzBass
Ahh ok, sorry, that happens to me a lot. I will post once, think about it, test it, etc and post a second time and people will miss my second one.
Yeah VB and C++ use really different type conversions and for that matter even data types.
Hey,
No hard feelings.
Thanks again for all of you hard work and time.
Please check back here in the next few days to see how this goes.
Till later,
JazzBass
No problem.
I am here alot during the work week so if you post again I will most likely see it.
Good luck.
Technocrat,
Hope this finds you well.
Well, I changed the code and complied it. I got the following warning in the output box when I performed a Rebuild of the exe.
When I perform a Release compile, it does not give me any warning messages for errors.
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE/winuser.rh(967) : warning RC4005: 'IDI_APPLICATION' : redefinition
This is where I could find what it's referring to. Do I need to worry about this? MSDN Library said it would use the second definition. This is how it was defined straight from microsoft.
Thanks very much.Code:/*
* Standard Icon IDs
*/
#ifdef RC_INVOKED
#define IDI_APPLICATION 32512
#define IDI_HAND 32513
#define IDI_QUESTION 32514
#define IDI_EXCLAMATION 32515
#define IDI_ASTERISK 32516
#if(WINVER >= 0x0400)
#define IDI_WINLOGO 32517
#endif /* WINVER >= 0x0400 */
#else
#define IDI_APPLICATION MAKEINTRESOURCE(32512)
...
JazzBass
I would not worry about it unless it does not work. It looks like it has a problem with one of the references to resource for that project. Since it is just a warning I would not sweat it.
Hi,
Thanks for your input. I won't worry about it.
I tried it on a 98 machine and it works! Only problem is that if the user chooses to cancel out of the MDAC setup, it asks to reboot and then it continues to extract the files it needs until the user finally agrees. Just a little minor thing, I guess.
I may just do a silent setup, but no screen comes up while it's installing so the user knows what's going on. Oh well.
Anyway, thanks again for all of you help and time. It's much appreciated.
JazzBass
Sure no problem