|
-
Mar 16th, 2006, 05:21 AM
#1
Thread Starter
Hyperactive Member
Why integer???
I am trying to learn API. I started out buy using the findwindow fuction.
It did not work until I changed the return type to integer.
From:
VB Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
To:
VB Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Everywhere I look, its show the return type as Long. If I use long, my results are just random numbers.
Why?
VB.NET 2003
-
Mar 16th, 2006, 05:24 AM
#2
Re: Why integer???
If you are using VB.NET then you should be using IntPtr rather than Integer.
FindWindow API returns the handle of the window and handles are stroed in IntPtr datatypes unlike VB 6.
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Mar 16th, 2006, 06:41 AM
#3
Re: Why integer???
Are you sure you have not looked at code for Classic VB rather then VB.NET? In classic VB (meaning version 6 and some of the earlier) integer was 16bit, while long was 32bit.
Today in VB.NET, an integer is finaly 32bit, hence an integer in VB.NET is the same as a long in VB 6.
PS: DOn't ask me why I know these things. I have never touched VB.NET..
- ØØ -
-
Mar 16th, 2006, 01:16 PM
#4
Thread Starter
Hyperactive Member
Re: Why integer???
Thanks, thats what I needed.
-
Mar 16th, 2006, 03:19 PM
#5
Re: Why integer???
My esteemed comrade Noteme is right, integers inany .NET language are 32-bit.
VB6 is at fault here really for perpetuating integers as being signed 16 bits rather than signed 32 bits.
You will find that there is very little API example code availabe for .NET languages. (C# does fare a little better than VB.net in this respect, but you should be using c# anyway but I'm biased). Roughly speaking if you are going to use Vb6 code to learn from then ... Vb6 long should be replaced with VB.net integer.
I don't live here any more.
-
Mar 16th, 2006, 03:35 PM
#6
Re: Why integer???
Or you can check out APIViewer 2004 in my sig, which has a .NET mode that has the changed declarations for you...
-
Mar 16th, 2006, 03:50 PM
#7
Re: Why integer???
 Originally Posted by wossname
My esteemed comrade Noteme is right, integers inany .NET language are 32-bit.
VB6 is at fault here really for perpetuating integers as being signed 16 bits rather than signed 32 bits.
You will find that there is very little API example code availabe for .NET languages. (C# does fare a little better than VB.net in this respect, but you should be using c# anyway  but I'm biased). Roughly speaking if you are going to use Vb6 code to learn from then ... Vb6 long should be replaced with VB.net integer.
How did you manage to use that much space to write exactly the same as I had already done?
-
Mar 16th, 2006, 03:54 PM
#8
Re: Why integer???
I learned all about talking complete garbage from you m00sy.
I don't live here any more.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|