Click here to Skip to main content
15,894,405 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# RegistryKey and GetType Pin
Ian Bowler12-Apr-05 7:36
Ian Bowler12-Apr-05 7:36 
GeneralRe: C# RegistryKey and GetType Pin
Brigg Thorp12-Apr-05 9:21
Brigg Thorp12-Apr-05 9:21 
GeneralRe: C# RegistryKey and GetType Pin
Dave Kreskowiak12-Apr-05 7:52
mveDave Kreskowiak12-Apr-05 7:52 
GeneralRe: C# RegistryKey and GetType Pin
Brigg Thorp12-Apr-05 9:25
Brigg Thorp12-Apr-05 9:25 
QuestionCan i stop people from deleting a file? Pin
Anthony Mushrow12-Apr-05 5:37
professionalAnthony Mushrow12-Apr-05 5:37 
AnswerRe: Can i stop people from deleting a file? Pin
Dave Kreskowiak12-Apr-05 7:21
mveDave Kreskowiak12-Apr-05 7:21 
AnswerRe: Can i stop people from deleting a file? Pin
afinnell15-Apr-05 13:55
afinnell15-Apr-05 13:55 
GeneralC# COM Interop Pin
s2111979212-Apr-05 4:30
s2111979212-Apr-05 4:30 
Hi,

I created an ATL COM object which i want to use from C#. I'm generating events from the ATL COM that's caught on the C# end.


<br />
[id(1), helpstring("method MyEvent")] HRESULT MyEvent([in,out] int* message);<br />
<br />
private static void MyEvent(ref int message)<br />
{<br />
   Console.Writeline("Got Event");<br />
}<br />
<br />


The problem is that the int* in the method is automatically marshalled to a ref int on the c# side. I want it to be marshalled to a IntPtr. So i decompiled the Interop.MyProject.dll and changed all the int32& in the necessary methods to native int.


.method public virtual instance void MailEvent(int32& A_1) cil managed
Becomes
.method public virtual instance void MailEvent(native int A_1) cil managed

Now i can use private static void MyEvent(IntPtr message) to catch the event.
But now the "Got Event" doesn't get printed out.
The event doesn't get caught.

Does anyone know why this shouldnt work?

BTW. I want to use an IntPtr so that i can send this structure through to the C# side.

c++

<br />
typedef struct Message<br />
{<br />
BSTR subject;<br />
....<br />
....<br />
} Message;<br />
<br />
Message *msg = new Message();<br />
MyEvent((int*)msg);<br />


c#

<br />
[StructLayoutAttribute(LayoutKind.Sequential)] <br />
public struct Message<br />
{<br />
   public string subject; <br />
}<br />
<br />
private static void MyEvent(IntPtr message)<br />
{<br />
   Message msg = new Message();<br />
   Marshal.PtrToStructure(message,msg);<br />
}<br />

GeneralMake an instance of a child form from a class file. Pin
Mike Jeferson12-Apr-05 4:23
Mike Jeferson12-Apr-05 4:23 
GeneralC# Connection to Northwind via SQL - HELP Pin
Jethro6312-Apr-05 4:08
Jethro6312-Apr-05 4:08 
GeneralRe: C# Connection to Northwind via SQL - HELP Pin
Luis Alonso Ramos12-Apr-05 6:34
Luis Alonso Ramos12-Apr-05 6:34 
GeneralRe: C# Connection to Northwind via SQL - HELP Pin
Jethro6312-Apr-05 15:59
Jethro6312-Apr-05 15:59 
GeneralRe: C# Connection to Northwind via SQL - HELP Pin
Dave Kreskowiak13-Apr-05 4:20
mveDave Kreskowiak13-Apr-05 4:20 
GeneralRe: C# Connection to Northwind via SQL - HELP Pin
Luis Alonso Ramos13-Apr-05 5:29
Luis Alonso Ramos13-Apr-05 5:29 
GeneralRe: C# Connection to Northwind via SQL - HELP Pin
Jethro6313-Apr-05 15:22
Jethro6313-Apr-05 15:22 
GeneralRe: C# Connection to Northwind via SQL - HELP Pin
Mushtaque Nizamani25-Oct-07 4:41
Mushtaque Nizamani25-Oct-07 4:41 
GeneralPainting Issue Pin
Mark_Harrison12-Apr-05 2:05
Mark_Harrison12-Apr-05 2:05 
GeneralRe: Painting Issue Pin
S. Senthil Kumar12-Apr-05 3:26
S. Senthil Kumar12-Apr-05 3:26 
Generalcreating code demo Pin
rmedo12-Apr-05 1:56
rmedo12-Apr-05 1:56 
GeneralRe: creating code demo Pin
eggie512-Apr-05 13:58
eggie512-Apr-05 13:58 
GeneralRe: creating code demo Pin
rmedo13-Apr-05 4:34
rmedo13-Apr-05 4:34 
GeneralC# &amp; XML &amp; nested loops problem (try 2) Pin
Anonymous12-Apr-05 1:47
Anonymous12-Apr-05 1:47 
GeneralRe: C# &amp; XML &amp; nested loops problem (try 2) Pin
hooray12-Apr-05 2:11
hooray12-Apr-05 2:11 
GeneralRe: C# &amp; XML &amp; nested loops problem (try 2) Pin
Anonymous12-Apr-05 2:38
Anonymous12-Apr-05 2:38 
GeneralC# &amp; XML &amp; nested loops problem Pin
Anonymous12-Apr-05 1:45
Anonymous12-Apr-05 1:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.