C# - Difference Between IntPtr And UIntPtr?
Aug 24, 2009I see everywhere people use IntPtr, is there any reason I should use UIntPtr, instead?
View 2 RepliesI see everywhere people use IntPtr, is there any reason I should use UIntPtr, instead?
View 2 RepliesAssume that I have this declaration (according to MSDN):
Private Declare Function PostMessage Lib "user32" ( _
ByVal hWnd As IntPtr, _
ByVal wMsg As UInteger, _
[code]....
And this is how I use it:
PostMessage(hWnd, 516, CType(2, UIntPtr), CType(0, UIntPtr))
Option Strict is turned On. So the questions are:
1. Do I need to use UIntPtr in declaration or it will be better to use UInteger?
2. Do I need to use CType function in these cases or there is a better way for this or I need to avoid declaring pointers?
What is the equivalent of IntPtr of Vb.Net in Vb6? For example what'll be the equivalent of the following 2 lines in Vb6?
View 1 RepliesHow can I convert IntPtr to Int64?
vb
Convert.ToInt64(GetForegroundWindow())
error :Unable to cast object of type 'System.IntPtr' to type 'System.IConvertible'.
I have a function that I need to pass data to but the only type of data the function is allowed to accept as a parameter is IntPtr (yep you guessed it, Windows APIs). Would I be able to actually pass anything useful to it? In the case I'm looking at right now it would be a List(Of T) that I need to pass to the function? At the moment I'm resorting to just using a class level object that both the calling method and the function that accepts IntPtr can access, but I would like to negate the need for this if possible.
View 6 Repliesi am using SendMessage to send a message with a LPTSTR in WPARAM from a dll to my vb.net form and i get it by overriding WndProc but the problem is when using Marshal.PtrToStringAuto on the WPARAM it doesn't work, the strange thing is that if i monitor WM_SETTEXT of the form and use PtrToStringAuto to get the string from LPARAM it works, i guess mine doesn't work that's because the dll is loaded by other application.
C++ DLL Proc
Code:
LRESULT CALLBACK CallWndProc(int nCode,WPARAM wParam,LPARAM lParam)
{
[Code]...
This sounds like a silly question, and it may not even be possible, but say I have a MemoryStream in my code. Is it possible to get the IntPtr of said MemoryStream?
View 3 RepliesThe idea with System.IntPtr is to represent an integer whose width in bits correspond to the size of a pointer in the hardware and operating system that the CLR is running in, it's platform specific in other words. It supports 32-bit and 64-bit architectures only.This is a legacy from old-style C API's where pointers and ints were frequently treated as interchangeable. The Win32 API has many such parameters, where the width varies with the underlying architecture thus the mess with porting of code from 32-bit to 64-bit (we already did this once when going from 16-bit to 32-bit, funny how we never learn...).In practice, as is mentioned in other responses, it can be used to hold unmanaged resource handles and pointers etc that stem from the underlying Win32 functions. It can also be used to hold integers of the natural size for current platform. You can also use IntPtr.Size to dtermine the size of a pointer on the current platform.SO when you explain this to a child ;) this would be used to let program's flow at the same speed at diffrent kinds of operating systems?
View 1 RepliesI am trying to setup a call back (delegate) in my code for the DirectSound.Notify so I will be called when the sound buffer reaches a certain postion druing play back. My Code is the following:
'Set up call back
Public Delegate Sub NotifyHandler()
'.....
Dim NotificationHandler As NotifyHandler
[code]....
I need to get the address of an integer and assign it to an IntPtr to use in an API.[code]...
View 3 Replieshow to retrive the raw data of the image pointed by an intptr.The thing is the detector gives the pointer to the acquired image and I need to retrieve the image rawdata from the given intptr.
View 1 Replieshow I can convert an Integer of an object handle to an IntPtr?
View 2 RepliesI'm trying to get the window of a game (jedi academy) I keep getting this error Cannot convert type 'integer' to system.intrptr This is were its underlined in blue DirectCast(Me.hWndGame, IntPtr),
Imports Microsoft.VisualBasic.CompilerServices
Imports System
Imports System.Runtime.InteropServices
[code]....
I need to explicitly convert my byte array into IntPtr to pass it to the third-party api. I've been looking through Runtime.InteropServices namespace but didn't find anything suitable.
View 2 RepliesAlways when i want to create a Executeable and i use the CodeDom Compiler i always get the Error:
The Type IntPtr is not defined
My Compiler Options:
options.ReferencedAssemblies.Add("System.dll")
[code].....
i need to save an array of intptrs as a part of a structure in a file, vb.net gives me "File I/O of a structure with field 'pList' of type 'IntPtr' is not valid." error, ok i figured and tried to convert them to integers and while it worked for other singular intptrs it did not for the array as it just throws me a conversion error. I then tried rebuilding the array in the new sub of the save structure and while that sorta worked(i think) it then gives a "bad size" error when saving. Im out of ideas, saving the array elements one by one would be suicide as the amount varies and is well in hundreds,
View 1 RepliesWe're in a strange situation with a legacy winforms VB.NET 1.1 application using ASMX web services. Trying to send a user Token from a WindowsIdentity object as a parameter to a WebMethod. I will be adding a 'HACK: comment. System.Security.Principal.WindowsIdentity.GetCurrent().Token
The token is of type IntPtr, the first problem is the WSDL being generated doesn't support IntPtr with the error of 'unsupported type'I'm aware this is a big WTF question and sounds insecure, so any simple helpful alternatives are welcome but there are a lot of constraints on how we can change this system, including complications with the hosting environment. So I would just like to get our piece of data over to the web service to save a lot of other headaches.
[Code]...
[Code]...
How do I convert this proper? (Option Strict On)
The System.Security.Principal.WindowsIdentity.Impersonate function takes a System.intptr parameter, which seems awfully useless in my situation (with my limited understanding). I am developing an intranet application that uses integrated security to authorize users page-by-page against a role associated with their Windows Identity. I have no passwords or anything of the sort. Simply a Windows username. For testing purposes, how could I possibly impersonate a Windows user based on their username? The "impersonate" method jumped out at me as obvious, but it takes an unexpected parameter.
View 4 RepliesI'm sure this is straightforward but I cannot find the correct string to get a google result. In VB.NET what is the difference between = (equals sign) and := (colon followed by equals sign)?
View 3 Repliescan anyone tell me book for VB.net for beginner and complee package of books important for VB. as i don't know anything abt VB.
what is difference between VB.net and asp.net and c#??
Possible Duplicate: What are the most important functional differences between C# and VB.NET? What are the basic difference between c# and VB.net?
View 3 Repliesknow the difference between C#.Net and VB.Net. I use C#.Net for my projects, but when ever I met with some other programmers they often called VB.Net more powerful and easy, than C#.Net. I always asked them "Why it is more powerful then C#, since it uses the same framework?" but still I didn't get any answers.
View 3 Replieswhat exactly distinguishes a COM component from a DLL? Isn't a COM component just a library of functions that can be called from another application? Why is using a COM component so much more complicated than just registering it like one would do with a DLL?
View 4 RepliesI'm looking for an explanation of the difference between
Dim sw1 = New StringWriter()
Dim sw2 As New StringWriter()
Both seem to instantiate new string writer instances that I can use.
I was under the assumption that VB's For Each loop was the same as a For Next loop. But when i try running the following code I do not get the expected result.
[Code]...
I have this code, first I thougt it should be the same but i cant acces the info in the same way .. why is this???
Dim tp(,) As Integer = {{1, 3, 5, 9, 7}, {34, 3, 4, 5, 6}}
Dim tpo(1)() As Integer
tpo(0) = New Integer() {1, 3, 5, 9, 7}
[code].....
The first one I use only one for each and the other one I use two .. why is this different? are noy they 2 dimensional arrays ???
What is the difference between VB and VB.NET?
explanation with examples preferred
The next code works fine in C#:
[Code]...
But this code crash with a OverflowException in VB.Net.
[Code]...
Both codes seems the same to me. What is the difference and how can I get the C# code converted to VB.Net?
For those who have experience, working with VB.NET, it's easier to use SlimDX or SDL? The tutorials for SlimDX are already written for .NET, but I've read that SDL it's a lot easier than DirectX itself.in my case, I just need 2D graphics.
View 4 Replies