473,658 Members | 2,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Marshal & Hwnd - Please Help.

I have the next code

byte[] data = new byte[14];
Marshal.Copy(th is.Hwnd, data, 0, 4);

this code compiled well, but when i execute the code receive a error.

How can copy this.Hwnd (Handle of MessageWindow type IntPtr) to the first 4
bytes in data ?

Thanks.
Nov 15 '05 #1
3 3051
Hi,
Your code tries to copy 4 bytes of data from the location pointed by IntPtr
(this.Hwnd).
If you want to copy the IntPtr value (not the data it points) you could use
such approach:

byte[] data = new byte[14];
int ptrValue= this.Hwnd.ToInt 32();
data[0] = (byte)ptrValue;
data[1] = (byte)ptrValue >> 8;
data[2] = (byte)ptrValue >> 16;
data[3] = (byte)ptrValue >> 24;

--
Andrew Gnenny
pulsar2003@/no-spam/email.ru (Please remove /no-spam/ for reply)
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Juan Irigoyen" <ju***********@ ono.com> wrote in message
news:zr******** *************@n ews.ono.com...
I have the next code

byte[] data = new byte[14];
Marshal.Copy(th is.Hwnd, data, 0, 4);

this code compiled well, but when i execute the code receive a error.

How can copy this.Hwnd (Handle of MessageWindow type IntPtr) to the first 4 bytes in data ?

Thanks.

Nov 15 '05 #2
Sorry this code have n error, Cannot implicity convert type 'int' to 'byte'

"Andrew Gnenny" <pulsar2003@/no-spam/email.ru> escribió en el mensaje
news:3f******** @nexus.validio. com.ua...
Hi,
Your code tries to copy 4 bytes of data from the location pointed by IntPtr (this.Hwnd).
If you want to copy the IntPtr value (not the data it points) you could use such approach:

byte[] data = new byte[14];
int ptrValue= this.Hwnd.ToInt 32();
data[0] = (byte)ptrValue;
data[1] = (byte)ptrValue >> 8;
data[2] = (byte)ptrValue >> 16;
data[3] = (byte)ptrValue >> 24;

--
Andrew Gnenny
pulsar2003@/no-spam/email.ru (Please remove /no-spam/ for reply)
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Juan Irigoyen" <ju***********@ ono.com> wrote in message
news:zr******** *************@n ews.ono.com...
I have the next code

byte[] data = new byte[14];
Marshal.Copy(th is.Hwnd, data, 0, 4);

this code compiled well, but when i execute the code receive a error.

How can copy this.Hwnd (Handle of MessageWindow type IntPtr) to the
first 4
bytes in data ?

Thanks.


Nov 15 '05 #3
Try this code:
byte[] data = new byte[14];
int ptrValue= this.Hwnd.ToInt 32();
data[0] = (byte)ptrValue;
data[1] = (byte)(ptrValue >> 8);
data[2] = (byte)(ptrValue >> 16);
data[3] = (byte)(ptrValue >> 24);

--
Andrew Gnenny
pulsar2003@/no-spam/email.ru (Please remove /no-spam/ for reply)
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Juan Irigoyen" <ju***********@ ono.com> wrote in message
news:7b******** *************@n ews.ono.com...
Sorry this code have n error, Cannot implicity convert type 'int' to 'byte'
"Andrew Gnenny" <pulsar2003@/no-spam/email.ru> escribió en el mensaje
news:3f******** @nexus.validio. com.ua...
Hi,
Your code tries to copy 4 bytes of data from the location pointed by

IntPtr
(this.Hwnd).
If you want to copy the IntPtr value (not the data it points) you could

use
such approach:

byte[] data = new byte[14];
int ptrValue= this.Hwnd.ToInt 32();
data[0] = (byte)ptrValue;
data[1] = (byte)ptrValue >> 8;
data[2] = (byte)ptrValue >> 16;
data[3] = (byte)ptrValue >> 24;

--
Andrew Gnenny
pulsar2003@/no-spam/email.ru (Please remove /no-spam/ for reply)
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Juan Irigoyen" <ju***********@ ono.com> wrote in message
news:zr******** *************@n ews.ono.com...
I have the next code

byte[] data = new byte[14];
Marshal.Copy(th is.Hwnd, data, 0, 4);

this code compiled well, but when i execute the code receive a error.

How can copy this.Hwnd (Handle of MessageWindow type IntPtr) to the

first
4
bytes in data ?

Thanks.



Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
28175
by: Ed Landau | last post by:
In VB6.0, I can put an image on a form and assign it's .picture property at run-time. In VBA (within MS Access), when I put down an image control on a form, it asks me for the source to the image (at design-time). Why? Why can't I find PictureBox in VBA within MS Access? And most importantly...why can't I put either in a Report within MS Access? What I really want is to be able to display pictures in an MS Access report (pictures...
0
2691
by: Johannes Unfried | last post by:
Problem Best practice needed to marshal STL data from managed code to unmanaged code & vice vers Details managed code is written in managed C++ & accesses the unmanaged code (i.e. lives in a mixed mode DLL unmanaged code is written in unmanaged C++ & resides in an unmanaged DL Product used is VS.NET 200 Please tell me what is the best practice for getting and setting data fro unmanaged to managed part when I have a class with...
5
3015
by: Adrian | last post by:
Hello, I'm currently converting a program at which needs to be able to dial and disconnect a specified DUN entry. The VB6 code is as follows and works fine, showing the dialog box for username and password etc.: Private Declare Function InternetHangUp Lib "wininet.dll" (ByVal dwConnection As Long, ByVal dwReserved As Long) As Long Private Declare Function InternetDial Lib "wininet.dll" (ByVal hWnd As Long, ByVal sConnectoid As String,...
5
4326
by: Matthew Hood | last post by:
Here's a interesting question for the guru's out there. I've created a VB.NET class library with a couple of forms that I have successfully got to work from within MS Access using COM interop and VBA. (Working, meaning it hasn't crashed on me yet... ;-). I Would anybody know how to take this VB.NET Winform (using it's handle, subclassing, or other means) and set it's parent to be the Access MDI client area so that it will behave as if...
1
2333
by: pangel83 | last post by:
I've been trying for days to write a piece of VB.NET code that will read from winamp's memory space the paths of the files from the current winamp playlist. The GETPLAYLISTFILE command of the winamp API will only return a pointer to the position of the asked path. An article available on http://msmvps.com/ch21st/archive/2004/02/26.aspx provides a VB6 implementation of this, using the ReadProcessMemory Windows API command. Through...
9
2764
by: Lloyd Dupont | last post by:
If I write a pure C# application, only using the standart publi API, no interop, the same binary should work well on32 bit, 64 bits and perhaps on the compact framework as well if I link against it. Now how could I achieve the same thing if I do interop and I have a managed C++ API? let say I have a managed C++ module compiled for 3 different target but with always the same interface: mycppmodule32.dll
0
2550
by: tristanlbailey | last post by:
I have been attempting to solve this problem for a few weeks now, but I'm not having much luck... I would like to create a seamless fading effect on each form/window in my program; one that, when an image is clicked with a mouse and held, the window fades away by approximately 50% transparency, and when the mouse button is released, fades back to opaque. I have been able to do this to an extent, with the SetLayeredWindowAttributes...
4
8810
by: Larry Smith | last post by:
Hi there, Does anyone know if this (example) is safe: internal static extern int GetWindowRect(IntPtr hWnd, ref RECT rect); int rc = GetWindowRect(hWnd, ref rect); if (rc == 0)
1
2880
by: bladepif | last post by:
Hello, I have a C++ dll that I can not link to may project, because it gives me an error that it is not a valid assembly or COM. I have 3 functions in this dll I need to use. - Initialize - convet MPEG frame to JPEG -Close The definition in the header file is like this:
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.