I am using function GetClassName for a given HWND. The function is giving error:
"Invalid access to memory location".

I guess the problem is in the out parameter. As per msdn, GetClassName takes:
1- hWnd [in]
   Type: HWND 
   A handle to the window and, indirectly, the class to which the window belongs.
2- lpClassName [out]
   Type: LPTSTR 
   The class name string.
3- nMaxCount [in]
   Type: int

Any ideas?
Please help..
Offending code not shown. What does your function call look like?
Hi Freddie

I am benefiting too much from your code in site..

Anyway, the call of my function is below:
HWND hWnd_v;
LPTSTR clsName_v; 
int numChr;

GetClassName (hWnd_v, clsName_v, numChr);

I tried to put & before the clsName_v but didnt work either.

I found a work around by splitting the switch statement that I am using.
However, I would appreciate if I know where is my mistake.

LPTSTR clsName_v means a pointer to a buffer provided by you - Windows will place the class name into this buffer if the call succeeds
int numChr is the length of the buffer in characters ;

(Note that GetClassName function is available as ANSI and Wide Char versions
so beware when calculating the size of the buffer;)


HWND hWnd_v; // to be set to some actual window handle value
char clsName_v[256]; //a buffer of  chars

GetClassNameA (hWnd_v, clsName_v, 256); //Specifically using ANSI version of the function 
Last edited on
Topic archived. No new replies allowed.