473,395 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

What the fsck am I doing wrong here

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!");
}
Nov 16 '05 #1
2 1418
Scott Manson <sd******@stewireless.com> wrote:
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!");
}


It would help if you'd tell us what your code is trying to do, what
FindWindow does, etc.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
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!");
}

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
13
by: Relaxin | last post by:
I'm just trying to figure out the terminology that is used on this board and wanted to know what is WAL and what roll does it play in Postgresql? Thanks
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
8
by: The Natural Philosopher | last post by:
This is so weird. What I am trying to do is to upload files and stuff them in a mysql database. Everything works except the file content is zero. using the load_file command from mysql...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.