473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

How to access a pointer to an existing structure?

Hi,
Iam trying to implement the QueryStatus method of IOleCommandTarget
interface.
public int QueryStatus(ref Guid pguidCmdGroup, int cCmds, IntPtr
prgCmds, IntPtr pCmdText)
{
object ocmd=Marshal.PtrToStructure(prgCmds,typeof(OLECMD) );

}
Basically, prgCmds is a pointer to an existing OLECMD structure, and I
want to fill in that structure. I tried to use Marshal.PtrToStructure
to obtain the structure. But it returns an object.The structure
definition of OLECMD is as follows:
[StructLayout(LayoutKind.Sequential)]
public struct OLECMD
{
public UInt32 cmdID;
public UInt64 cmdf;
}
I want to set the value of cmdf. How to do it?Please somebody help me
in this regard.

Thanks in advance,
Sujoan.

Apr 1 '06 #1
1 1326
Sujoan,

Please don't multipost to different groups.

public int QueryStatus(ref Guid pguidCmdGroup, int cCmds, IntPtr
prgCmds, IntPtr pCmdText)
It would be easier if you changed the signature to

public int QueryStatus(ref Guid pguidCmdGroup, int cCmds, [In, Out]
ref OLECMD prgCmds, IntPtr pCmdText)

I want to set the value of cmdf. How to do it?


OLECMD ocmd = Marshal.PtrToStructure(prgCmds,typeof(OLECMD));
ocmd.cmdf = 42;
Marshal.StructureToPtr(ocmd, prgCmds, false);
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Apr 1 '06 #2

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

Similar topics

5
by: Claudio Grondi | last post by:
Background information: --------------------------------- in order to monitor mainboard sensory data as fan speeds, temperatures, applications like SpeedFan http://www.almico.com/speedfan.php or...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
35
by: deko | last post by:
Do I get more scalability if I split my database? The way I calculate things now, I'll be lucky to get 100,000 records in my Access 2003 mdb. Here some math: Max mdb/mde size = 2000 x 1024 =...
18
by: steve | last post by:
I'm trying to create a structure of three pointers to doubles. For which I have: typedef struct { double *lst_t, *lst_vc, *lst_ic; } last_values; I then need to allocate space for...
23
by: bluejack | last post by:
Ahoy... before I go off scouring particular platforms for specialized answers, I thought I would see if there is a portable C answer to this question: I want a function pointer that, when...
0
by: Sujoan | last post by:
Hi, Iam trying to implement the QueryStatus method of IOleCommandTarget interface. public int QueryStatus(ref Guid pguidCmdGroup, int cCmds, IntPtr prgCmds, IntPtr pCmdText) { object...
5
by: Dilip | last post by:
Hi Folks I know the C++ standard doesn't talk about threads. However I am a little bit curious as to what might or might not happen with a particular scenario I encountered in my project. Its...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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,...
0
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...

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.