Click here to Skip to main content
15,896,514 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to draw a rounded bitmap? Pin
Shog94-Dec-02 20:27
sitebuilderShog94-Dec-02 20:27 
GeneralRe: How to draw a rounded bitmap? Pin
Paul M Watt5-Dec-02 5:42
mentorPaul M Watt5-Dec-02 5:42 
AnswerRe: How to draw a rounded bitmap? Pin
Paul M Watt5-Dec-02 5:45
mentorPaul M Watt5-Dec-02 5:45 
QuestionHow to translate this (masm32 in VC++) ? Pin
chen4-Dec-02 19:34
chen4-Dec-02 19:34 
GeneralReturn string from vc dll Pin
suresh_sathya4-Dec-02 19:06
suresh_sathya4-Dec-02 19:06 
GeneralRe: Return string from vc dll Pin
Rickard Andersson204-Dec-02 21:05
Rickard Andersson204-Dec-02 21:05 
GeneralRe: Return string from vc dll Pin
suresh_sathya4-Dec-02 21:44
suresh_sathya4-Dec-02 21:44 
GeneralRe: Return string from vc dll Pin
Johann Gerell4-Dec-02 22:47
Johann Gerell4-Dec-02 22:47 
Ok,

All three of szIEVersion, "IEVersion not found" and "Open Key Failed" are non-static local variables, i.e., they are declared at function scope. This means that they are not valid once the program runs out of their scope, i.e., the function returns. They are only valid inside the function.

My suggestion is that you instead pass the char array along with its max length as parameters to the function and return TRUE or FALSE if success or failure, and copy "IEVersion not found" and "Open Key Failed" where you call this function, based on the return value. Like this:

extern "C" BOOL _stdcall ReturnIEVersion(LPTSTR pszIEVersion, INT nMaxLen)
{
  HKEY hKey;
  DWORD dwType = REG_SZ;
  DWORD dwSize = nMaxLen + 1;
  LPCTSTR pszKey = _T("Software\\Microsoft\\Internet Explorer");

  if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, pszKey, 0, KEY_READ, &hKey))
  {
    if(ERROR_SUCCESS == RegQueryValueEx(hKey, _T("Version"), NULL, &dwType, LPBYTE(pszIEVersion), &dwSize))
    {
      return TRUE;
    }
    else
    {
      return FALSE;
    }

    RegCloseKey(hKey);
  }
  else
  {
    return FALSE;
  }
}

QuestionHow can run my VC program in a computer without VC installed? Pin
Sstar4-Dec-02 18:59
Sstar4-Dec-02 18:59 
AnswerRe: How can run my VC program in a computer without VC installed? Pin
Christian Graus4-Dec-02 19:10
protectorChristian Graus4-Dec-02 19:10 
AnswerRe: How can run my VC program in a computer without VC installed? Pin
Michael Dunn4-Dec-02 19:12
sitebuilderMichael Dunn4-Dec-02 19:12 
AnswerRe: How can run my VC program in a computer without VC installed? Pin
Dov Sherman5-Dec-02 2:12
Dov Sherman5-Dec-02 2:12 
QuestionCan we search SQL (VC++) combine with Boolean? Pin
Anonymous4-Dec-02 18:27
Anonymous4-Dec-02 18:27 
AnswerRe: Can we search SQL (VC++) combine with Boolean? Pin
Nick Parker4-Dec-02 18:35
protectorNick Parker4-Dec-02 18:35 
GeneralRe: Can we search SQL (VC++) combine with Boolean? Pin
Anonymous5-Dec-02 3:41
Anonymous5-Dec-02 3:41 
AnswerRe: Can we search SQL (VC++) combine with Boolean? Pin
RedZenBird4-Dec-02 18:41
RedZenBird4-Dec-02 18:41 
GeneralRe: Can we search SQL (VC++) combine with Boolean? Pin
Anonymous5-Dec-02 3:41
Anonymous5-Dec-02 3:41 
AnswerRe: Can we search SQL (VC++) combine with Boolean? Pin
RedZenBird4-Dec-02 19:01
RedZenBird4-Dec-02 19:01 
GeneralRe: Can we search SQL (VC++) combine with Boolean? Pin
Anonymous5-Dec-02 3:36
Anonymous5-Dec-02 3:36 
GeneralRe: It works, thanks! Pin
Anonymous5-Dec-02 3:37
Anonymous5-Dec-02 3:37 
AnswerRe: Can we search SQL (VC++) combine with Boolean? Pin
RChin4-Dec-02 23:52
RChin4-Dec-02 23:52 
GeneralRe: Can we search SQL (VC++) combine with Boolean? Pin
Anonymous5-Dec-02 3:42
Anonymous5-Dec-02 3:42 
GeneralAn easy one for you pro's... Pin
Brent Lamborn4-Dec-02 17:58
Brent Lamborn4-Dec-02 17:58 
GeneralRe: An easy one for you pro's... Pin
Christian Graus4-Dec-02 18:15
protectorChristian Graus4-Dec-02 18:15 
GeneralRe: An easy one for you pro's... Pin
Nick Parker4-Dec-02 18:21
protectorNick Parker4-Dec-02 18:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.