Results 1 to 16 of 16

Thread: Please look at this link

  1. #1

    Thread Starter
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Smile

    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
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  2. #2
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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;
                    
    charpos;

        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(hKLMTEXT("FullInstallVer"), NULLNULL, (BYTE*) szValue, &dwKeySize);
            
    ldwReg RegQueryValueEx(hKLMTEXT("Full21Install"), NULLNULL, (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;
        }

    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  3. #3

    Thread Starter
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Talking Thank You Very Much Technocrat, Another Quick Question

    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
    Last edited by JazzBass; Mar 14th, 2001 at 06:07 AM.
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  4. #4
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  5. #5

    Thread Starter
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Talking TechoCrat Don't go away quite yet

    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.

    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;
    	}
    }
    Thank you very much.

    JazzBass
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  6. #6
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  7. #7
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  8. #8
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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?
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  9. #9

    Thread Starter
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Talking Sorry about that

    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
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  10. #10
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  11. #11

    Thread Starter
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Smile Technocrat, mucho thanks

    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
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  12. #12
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    No problem.

    I am here alot during the work week so if you post again I will most likely see it.

    Good luck.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  13. #13

    Thread Starter
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Smile Technocrat

    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.

    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)
    
    ...
    Thanks very much.

    JazzBass
    Last edited by JazzBass; Mar 16th, 2001 at 04:18 AM.
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  14. #14
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  15. #15

    Thread Starter
    Hyperactive Member JazzBass's Avatar
    Join Date
    Jun 1999
    Posts
    393

    Talking Thanks Techocrat

    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
    JazzBass
    In the .NET era
    Trying to remember VB6
    Progress:
    XP Professional @ Home
    and @ the Office

  16. #16
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Sure no problem
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width