Hi Scott,
In addition to what Jon said I will try to guess what you are doing.
I think that you are trying to use GetClassName function from win API , if
that is so, bldr is an out parameter, meaning that you need to create a
buffer where the function will place the name of the class, you are not
doing that, that may be the problem, change the stringbuilder to a char[] of
255 ( the third arg contain the size of the array ) and see what happen
This is the definition of GetClassName function , maybe somebody can give
you the correct way to P/Invoke it.
int GetClassName(
HWND hWnd, // handle to window
LPTSTR lpClassName, // class name
int nMaxCount // size of class name buffer
);Parameters
hWnd
[in] Handle to the window and, indirectly, the class to which the window
belongs.
lpClassName
[out] Pointer to the buffer that is to receive the class name string.
nMaxCount
[in] Specifies the length, in TCHARs, of the buffer pointed to by the
lpClassName parameter. The class name string is truncated if it is longer
than the buffer.
Return Values
Hope this help,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Scott Manson" <sd******@stewireless.com> wrote in message
news:aa**************************@posting.google.c om...
StringBuilder bldr=new StringBuilder();
int res=GetClassName(0x00240110,bldr,255);
Debug.WriteLine(bldr.ToString());
if(bldr.ToString()=="AfxFrameOrView42s")
Debug.Write("Things SHOULD work");
hWnd=FindWindow(bldr.ToString(),"");
if(hWnd==(IntPtr) 0)
{
Debug.WriteLine(" but they obviously dont!");
}
// The following is just in case I fscked a parameter
hWnd=FindWindow(bldr.ToString(),null);
if(hWnd==(IntPtr) 0)
{
Debug.WriteLine("Things SHOULD WORK but they obviously dont!");
}