473,750 Members | 2,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What the fsck am I doing wrong here

StringBuilder bldr=new StringBuilder() ;
int res=GetClassNam e(0x00240110,bl dr,255);
Debug.WriteLine (bldr.ToString( ));
if(bldr.ToStrin g()=="AfxFrameO rView42s")
Debug.Write("Th ings SHOULD work");
hWnd=FindWindow (bldr.ToString( ),"");
if(hWnd==(IntPt r) 0)
{
Debug.WriteLine (" but they obviously dont!");
}
// The following is just in case I fscked a parameter
hWnd=FindWindow (bldr.ToString( ),null);
if(hWnd==(IntPt r) 0)
{
Debug.WriteLine ("Things SHOULD WORK but they obviously dont!");
}
Nov 16 '05 #1
2 1431
Scott Manson <sd******@stewi reless.com> wrote:
StringBuilder bldr=new StringBuilder() ;
int res=GetClassNam e(0x00240110,bl dr,255);
Debug.WriteLine (bldr.ToString( ));
if(bldr.ToStrin g()=="AfxFrameO rView42s")
Debug.Write("Th ings SHOULD work");
hWnd=FindWindow (bldr.ToString( ),"");
if(hWnd==(IntPt r) 0)
{
Debug.WriteLine (" but they obviously dont!");
}
// The following is just in case I fscked a parameter
hWnd=FindWindow (bldr.ToString( ),null);
if(hWnd==(IntPt r) 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.co m>
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******@stewi reless.com> wrote in message
news:aa******** *************** ***@posting.goo gle.com...
StringBuilder bldr=new StringBuilder() ;
int res=GetClassNam e(0x00240110,bl dr,255);
Debug.WriteLine (bldr.ToString( ));
if(bldr.ToStrin g()=="AfxFrameO rView42s")
Debug.Write("Th ings SHOULD work");
hWnd=FindWindow (bldr.ToString( ),"");
if(hWnd==(IntPt r) 0)
{
Debug.WriteLine (" but they obviously dont!");
}
// The following is just in case I fscked a parameter
hWnd=FindWindow (bldr.ToString( ),null);
if(hWnd==(IntPt r) 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
14809
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 software giant such as Microsoft SQL Server, Oracle, and Sybase? Is PostgreSQL reliable enough to be used for high-end commercial application? Thanks
13
9187
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
5053
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
3880
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 command line as 'root' works and i can download the inserted file ok.
0
8999
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8836
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9256
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6803
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4712
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4885
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.