What Is Equivalent Of IntPtr
Jun 28, 2009What 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 RepliesWhat 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 RepliesI see everywhere people use IntPtr, is there any reason I should use UIntPtr, instead?
View 2 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 know that AndAlso is equivalent to && and OrElse is equivalent to ||. But what is the cleanest way to achieve the equivalent of Visual Basic's And and Or in C#?For example, consider the following VB.NET code.The ValidateForControl method performs some validation and returns whether the state of the specified control is valid. The entire input form is valid if all controls are valid. However, each control must be individually validated even if one is invalid (which requires the operator not to short-circuit). Visual Basic's And operator is perfect for this situation, but unfortunately there's no equivalent operator in C# as far as I know (&& short-circuits).
[Code]...
I am Validating a TextBox on it's KeyPress Event in VB.
VB.Net
If InStr("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`~!@#$%^&*()_+|[]{};:<>/?,.'" & """" & Chr(8), Chr(KeyAscii)) = 0 Then KeyAscii = 0
What will be it's equivalent in C# ?
Let me know how can i use this Err in c#.This is VB Code:
If Len(sPart1) <> PART1_LENGTH Then
Err.Raise(vbObjectError, , "Part 1 must be " & PART1_LENGTH)
[code]......
What I am trying to do is to check if a value matches one of two numbers (and easily be able to add to the numbers to compare to). Rather than doing a longer-winded way such as: [Code] I have found that this only works when SectionID is 2 or PageID is 8. If SectionID is 3 or PageID is 12 then it doesn't work. Why is this and what can I do to try to get around the problem?
View 3 Replieswhat is the equivalent for OLE in .net
View 1 RepliesI'm normally at home in C#, and I'm looking at a performance issue in some VB.Net code -- I want to be able to compare something to the default value for a type (kind like C#'s default keyword).
[Code]...
I am relatively new to Visual Basic. When it comes to logging, in Java I use log4j for logging.What is the equivalent in Visual Basic and can you please guide me to a good tutorial?
View 1 Repliesprivate bool txtRegExStringIsValid(string textToValidate)
{
Regex TheRegExpression;
string TheTextToValidate;
[code]....
I've got a large codebase which I'd like to expose to plugin authors to allow them to use VB.Net Express to code plugins for a server app, which is not available to them. My problem is that even with obfuscation, I'd rather not distribute the complete app and/or dlls, as even with obfuscation peeling apart a .NET assembly and puzzling out code is relatively easy to do. I'm interested in this because the licensor I obtain the code from requires me to protect IP and assets and while distributing .NET apps opens up the app to disassembly, keeping the server app private and allowing users to utilize a skeleton dll to code against is a happy medium.
What I'm looking for is some way or a utility to go through my server app source code and create a codeless version of the app which only contains method and property signatures.The intent is to provide a stub .NET dll for them to add as a reference and code against as if they were directly interacting with the server, without actually providing the server code to them, compiled or not. I can of course do this by hand but there are over 90 classes and hundreds of thousands of lines of code I'd rather not spend a week hand tweaking. Also, this presents a problem whenever new methods or code are added to the project. Finally, two separate projects is an even worse scenario.Because people will post suggestions that have little or nothing to do with the question, here's a short, clear example. I want to turn this class:
Public Class MyServer
Public ReadOnly Property Name() As String
Get
Return "Whatever"
[code].....
What is the vb.net expression of this c# expression ?
Frame.GetController<ShowNavigationItemController>().CustomShowNavigationItem += new EventHandler<CustomShowNavigationItemEventArgs>(WindowController1_CustomShowNavigationItem);
I'm looking at some old ASP code that contains the following:
Set objDSE = GetObject("LDAP://RootDSE")
Set objSysInfo = CreateObject("adsysteminfo")
Set objUser= Getobject("LDAP://" & Replace(objSysInfo.UserName,"/","/"))
dtmValue = objUser.PasswordLastChanged
[code]....
This is for an intranet app that uses integrated authentication. Is there a replacement for the ASP adsysteinfo object? I can probably port most of the LDAP calls using System.DirectoryServices.DirectoryEntry, but is there a better/easier way to do this in ASP.NET (VB.Net or C#)? how to convert the ASP object properties to DirectoryEntry properties?
I have made an application in vb6 abd now trying to do the same in visual studio 2005. In vb6 i was using MSFlexgrid and its .Textmatrix properties. Would like to know what is the .Texmatrix equivalent for .net. When i pasted the code form vb6 i get the following error...
'TextMatrix' is not a member of 'AxMSFlexGridLib.AxMSFlexGrid'