473,661 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using System.IntPtr

I need to get a pointer of a variable...
How can I get it ?

for example:
Dim a() as CStructure
Dim z as System.IntPtr

z = ??????

Sushi
Nov 21 '05 #1
6 22441
The Marshal class has methods to help in this.

See Marshal.UnsafeA ddressOfPinnedA rrayElement.

You can create and use unmananged blocks of memory with Marshal.AllocHG lobal
and it's related methods

Vou can copy to and from C structs with StructureToPtr and PtrToStructure.

HTH

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Sushi" <su********@hot mail.com> wrote in message
news:e7******** ******@TK2MSFTN GP14.phx.gbl...
I need to get a pointer of a variable...
How can I get it ?

for example:
Dim a() as CStructure
Dim z as System.IntPtr

z = ??????

Sushi

Nov 21 '05 #2
"Sushi" <su********@hot mail.com> schrieb:
I need to get a pointer of a variable...
Variables that are declared as a reference type are "type-safe pointers":

\\\
Dim f1 As New Foo()
Dim f2 As Foo = f1 ' Points to the same instance as 'f1'.
///
How can I get it ?

for example:
Dim a() as CStructure
Dim z as System.IntPtr


What exactly do you want to archieve/to do with the pointer?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3
I will try to explain better

I want to execute some TrackServer functions...
Follow the prototype

COMSVCSLib.IGet AppData.GetApps (ByRef nApps As System.UInt32, ByVal aAppData
As System.IntPtr)

So
aAppData is pointer of an array of COMSVCSLib.CApp Data

In another words...
pAppData() As COMSVCSLib.CApp Data
aAppData As IntPtr = pAppData
Well...
After I get this IntPtr, I will need to convert this IntPtr to the pAppData
array
Did you understand me ?

Thanks for all,
Sushi
Nov 21 '05 #4
You need to declare a VB structure that corresponds to the layout of the C
structure that you are passed from the unmanaged side. Once you have that
you can use Marshal.PtrToSt ructure to obtain the contents of your structure.
For an array of structures you need to modify the IntPtr that you have to
the offset of the particular array element that you wish to access.

Unfortunately I can't find a reference to the structure you're trying to
grab.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Sushi" <su********@ter ra.com.br> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
I will try to explain better

I want to execute some TrackServer functions...
Follow the prototype

COMSVCSLib.IGet AppData.GetApps (ByRef nApps As System.UInt32, ByVal
aAppData
As System.IntPtr)

So
aAppData is pointer of an array of COMSVCSLib.CApp Data

In another words...
pAppData() As COMSVCSLib.CApp Data
aAppData As IntPtr = pAppData
Well...
After I get this IntPtr, I will need to convert this IntPtr to the
pAppData
array
Did you understand me ?

Thanks for all,
Sushi

Nov 21 '05 #5
I'm sure that if you can obtain this book it will be useful...

http://www.webtropy.com/articles/art...rop=COMSVCSLib

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Sushi" <su********@ter ra.com.br> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
I will try to explain better

I want to execute some TrackServer functions...
Follow the prototype

COMSVCSLib.IGet AppData.GetApps (ByRef nApps As System.UInt32, ByVal
aAppData
As System.IntPtr)

So
aAppData is pointer of an array of COMSVCSLib.CApp Data

In another words...
pAppData() As COMSVCSLib.CApp Data
aAppData As IntPtr = pAppData
Well...
After I get this IntPtr, I will need to convert this IntPtr to the
pAppData
array
Did you understand me ?

Thanks for all,
Sushi

Nov 21 '05 #6
thanks... I will try to create a structure in vb.net...

the reference is COMSVCSLib...
I already saw this article... but it's doesn't help me more than the object
browser for COMSVCS :-))))

"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
I'm sure that if you can obtain this book it will be useful...

http://www.webtropy.com/articles/art...rop=COMSVCSLib

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Sushi" <su********@ter ra.com.br> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
I will try to explain better

I want to execute some TrackServer functions...
Follow the prototype

COMSVCSLib.IGet AppData.GetApps (ByRef nApps As System.UInt32, ByVal
aAppData
As System.IntPtr)

So
aAppData is pointer of an array of COMSVCSLib.CApp Data

In another words...
pAppData() As COMSVCSLib.CApp Data
aAppData As IntPtr = pAppData
Well...
After I get this IntPtr, I will need to convert this IntPtr to the
pAppData
array
Did you understand me ?

Thanks for all,
Sushi


Nov 21 '05 #7

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

Similar topics

1
2055
by: C | last post by:
Hi, I have a C# Web Application. I am Referencing System.Web In teh code behind of one of my pages I have below imports- using System.Web.UI;
4
7560
by: Daisy | last post by:
Having a weird problem... Just moving some code into new classes & methods. Originally, I created a new instance of "Game" (my form), and it created a new DX Device using: _device = new Device(0, DeviceType.Hardware, _form, CreateFlags.SoftwareVertexProcessing, _presParams);
2
1514
by: ScOe | last post by:
I have directx namespace which contains few class-es (dx wrapper) Direct3d.Device expect System.IntPtr in passed parameters. When using it in main class i pass "this" as parameter .. how do i pass IntPtr from main class to my custom class? i tried with form.Handle but that doesnt work ...
4
3410
by: marcelino | last post by:
Hi, I have c# express beta I try to write the following using clause: System.Runtime.Remoting.Channels.Http; because I want to create a http channel. HttpChannel aJobChannel = new HttpChannel(4000);
4
5392
by: Manuel Costa | last post by:
How the hell do i convert System::IntPtr to HDC? manuel
2
3489
by: Ryan | last post by:
Hi, I receive an access denied error (see below) when attempting to send an email with BodyFormat=MailFormat.Html from an asp.net page. Exactly the same code works fine in a console application, and also succeeds from the asp.net page with BodyFormat=MailFormat.Text. I've recently upgraded from W2K SP4 to WinXP SP2 and am using .Net Framework v1.1 SP1. The code worked fine under W2K SP4.
9
13331
by: garyusenet | last post by:
I am using a C# solution that somebody kindly sent me. It was a console application. I am trying to get use of the MessageBox. I have added the following using directive to the namespaces at the start of the program : - using System; // I've added this...
11
3496
by: Ed Bitzer | last post by:
I have been able using the namespace System.Web.Mail and its method Smtp.mail.send to mail simple text messages to a small group within our 55 and older community. I need help expanding the programs capabilities. Searching this forum I did not find any related information so if I have chosen poorly, I would appreciate a suggestion of a more appropriate dotnet forum. Now what I wish is the ability to send bcc's rather than to: (would be...
2
4642
by: karthi84 | last post by:
Hi Experts, i have created a web application which has an option to edit the web config file from the web page. when i create an installer for this project using web setup project in VS2008 and install it, the codes are copied to the virtual directory under Inetpub. when i try to edit the web.config file it throws an exception access is denied to web.config file. but the same project works fine if i copy the file to some other location and...
0
8432
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
8343
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
8855
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
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7364
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...
0
5653
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
4179
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...
2
1743
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.