Questions tagged [intptr]

IntPtr is a .NET Framework platform-specific type that is used to represent a pointer or a handle.

IntPtr is a .NET Framework platform-specific type that is used to represent a pointer or a handle.

296 questions
0
votes
2 answers

Access Violation Exception using the method Marshal.Copy()

I'm writing a simple OpenCV application using .NET which the goal is to render the webcam stream on a simple window. Here's the code I use to do this: private static BitmapSource ToBitmapSource(IImage image) { using (System.Drawing.Bitmap source…
user1364743
  • 5,283
  • 6
  • 51
  • 90
0
votes
3 answers

How to declare a IntPtr?

I have a Window handle Picker and it says my handle is 0094167C. When I declare the variable in c# the letter in this code gives an error. How to declare? public const IntPtr WinHandle = 0094167C;
PassionateDeveloper
  • 14,558
  • 34
  • 107
  • 176
0
votes
0 answers

how to create the bitmap from intptr

i am making a video stegnaography project, in which I got the clone of the selected frames from the video and then I have to replace these embedded frames with the real frames in the video. I have used the avifile library so far and i use the cut…
0
votes
1 answer

Changing the string to which an IntPtr is pointing

In my C# application I have a variable lpData of type IntPtr (received from a call to unmanaged code), and it points to a string. I have to replace this string with another value. I tried: int RegQueryValueExW_Hooked( IntPtr hKey, …
L-Four
  • 13,345
  • 9
  • 65
  • 109
0
votes
1 answer

How does this bitmask apply to LParam (WM_HOTKEY)

Currently I am working on a simple class library to handle global hot keys with the help of various blog posts and SO answers. Consider this integral segment of code that I have put together. protected override void WndProc(ref Message m) { …
Caster Troy
  • 2,796
  • 2
  • 25
  • 45
0
votes
1 answer

C# Pinvoke IntPtr in structs and memory

If i have understood right, when using structs with non blitable values, the struct data from unmanaged memory is copied into the managed memory (basically having the same struct twice). Also if im not wrong, IntPtr variables, are stored in managed…
Cristiano Coelho
  • 1,675
  • 4
  • 27
  • 50
0
votes
1 answer

Reading Attached Image directly form memory using Autocad .Net API

I have a large JPEG image (10000*11000px), attached to an Autocad drawing, that I want to crop multiple times. I cannot load it into memory using .Net, I get an out of memory exception. the only thing I think I can do is read it directly from…
dioslibre
  • 177
  • 1
  • 5
0
votes
1 answer

Issue with size of IntPtr

Yesterday, I posted an issue regarding passing some int** and double** from C# to C++. How to import a C++ function with int** and double** parameters Fortunately, I got some good help. Here is my new code: [DllImport("opendsp.dll", SetLastError =…
diditexas
  • 121
  • 1
  • 10
0
votes
1 answer

Pendulum Swinging Strangely, IntPtr Overflows

My code isn't working! I've commented out my problems with /**'s. I have a OutOfMemory exception when I close the pendulum form as I am passing an IntPtr handle and it becomes to large. I also have a problem making the pendulum swing and loose…
Corey Ford
  • 178
  • 1
  • 13
0
votes
0 answers

Passing structs as intptrs or ref to unmanaged code

I've been trying to pass information to/from c# into a c++ dll. I'm not able to alter the dll at all. Basically, i've found a method that works - but i don't quite understand why this method works, when others don't. If i can get some sort of…
user2477533
  • 201
  • 1
  • 2
  • 10
0
votes
0 answers

Create and Save a Bitmap from an IntPtr c#

In my application I scan an image from a TWAIN device, then, I need to save this image to a local disk. All I have is an IntPtr that references the image byte data array. How can I create a Bitmap object using the IntPtr value? I tried with: Bitmap…
Lucas Lima
  • 43
  • 1
  • 6
0
votes
1 answer

Getting AccessViolationException on client PCs

Does anyone have experience using EZTwain's BARCODE_Recognize function? I'm wondering why I'm getting an AccessViolationException in my program when trying to use the Dosadi EZTwain library to recognize bar codes from scanned images. This program…
Zack
  • 2,789
  • 33
  • 60
0
votes
1 answer

How to free properly a IntPtr pointing to a unmanaged array?

I allocate IntPtr pointing to an array of struct to be used with unmanaged code. I found lot of resources on this subject and here is my final method (seems to work well): public IntPtr ArrayToPtr(T[] array) { int size = array.Length; int…
Eric David
  • 261
  • 3
  • 14
0
votes
1 answer

Using IntPtr with IComparer

Three related questions here: The IntPtr structure apparently does not implement < and > operators. Is there a way to perform this comparison without converting the structure to an int or long? Why are the < and > operators not implemented on this…
Raheel Khan
  • 14,205
  • 13
  • 80
  • 168
0
votes
2 answers

To call a method that requires IntPtr, is it better to use /unsafe, or Marshal.AllocHGlobal?

I have a class that will have a few instances persistent throughout the duration of the application. These objects will each need to call a dll method that appends data from an existing float[] buffer, and passes the full dataset to a DLL method…
Dax Fohl
  • 10,654
  • 6
  • 46
  • 90