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
-1
votes
1 answer

Call function in C++ dll from C#

I'm trying to call a function in a C++ dll, from C# code. The C++ function : #ifdef NT2000 __declspec(dllexport) #endif void MyFunction ( long *Code, long Number, …
-1
votes
1 answer

C++ unmanaged function callback char to C# char

I have a C# form. I am calling unmanaged functions from a C++ dll. I have a callback called FUNDownDevCBEx this returns variables int nType, IntPtr pData. So pointing to the struct _tagGPSMDVRInfo p = (_tagGPSMDVRInfo)Marshal.PtrToStructure(pData,…
MALKAVIAN
  • 131
  • 14
-1
votes
1 answer

C# IntPtr values

I would like to know what the different value of IntPtr mean. For example, I know that 202 means left button up. Where can I find a list of the values? I am particularly interested in the meaning of 562, 274, and 161. Thanks!
-1
votes
1 answer

IntPtr to three dimensional array

I am using a C++ dll into my C# project. Using pInvoke (Platform Invoke). My C++ code returns a double***, and the C# function returns a IntPtr. I have the dimensions of the matrix on both sides, they are just not constant. On C# side I…
Pedro Henrique
  • 680
  • 7
  • 22
-1
votes
1 answer

Passing FileStream to IntPtr buffer

I'm having problems trying to read a file directly from the hard drive with IntPtr, Currently I'm reading it by first using FileStream to pass it to a byte array, and then copying the byte array to the IntPtr. But this method causes overflow when…
MythicManiac
  • 445
  • 1
  • 4
  • 11
-2
votes
1 answer

How to get this line of code to work on x64 SendMessage()

We are trying to turn the monitor off via code and turn it back on via code. We found code that works however it uses user32.dll and does not seem to work in 64 bit mode like the rest of our software (yes i did try the obvious user64.dll) Any…
-2
votes
1 answer

Passing byte[] as IntPtr by PInvoke to memset

I need to pass a byte array to memset, which due to P/Invoke clunkiness takes IntPtr. Tested by hand, it works, but I am seeking theoretical confirmation. Is this method correct? [DllImport("msvcrt.dll", EntryPoint = "memset", CallingConvention =…
ArekBulski
  • 4,520
  • 4
  • 39
  • 61
-2
votes
1 answer

Get pointer to unmanaged memory in C# from C++

I've been given a C++ DLL that allocates memory. It has several functions that need me to pass it the pointer to this allocated memory. I'm working in C# so I need to keep this pointer around, so I can pass it back to the C++ DLL when needed. The…
NielW
  • 3,626
  • 1
  • 30
  • 38
-3
votes
1 answer

Should I free all of IntPtr's with FreeHGlobal once I'm done with them?

I have a lot of IntPtr's in my project, some of them have been returned from a my dll, hence, I have not allocated memory for them using Marshal.AllocHGlobal() [DllImport(Dll, CallingConvention = CallingConvention.Cdecl)] private static extern…
-3
votes
2 answers

Why can I not use a value inside a IntPtr method?

Besides the wrong use of DLLs, when I try to use the theTestValue inside the IntPtr method the IntelliSense marks it as fail. I would like to know why this is happening because I need to use a bool from outside inside this method. public partial…
user3772108
  • 854
  • 2
  • 14
  • 32
-5
votes
1 answer

for loop from intPtr, how?

How do I write a for loop to iterate over an array of floats, given the intPtr for the start of the array? It's C# in Unity, so I know the bytes of a float are 4. But am having only crashes when trying to increment from the intPtr by the simple use…
Confused
  • 6,048
  • 6
  • 34
  • 75
1 2 3
19
20