Click here to Skip to main content
15,893,668 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: Where to start? Pin
Michael Dunn30-Jun-06 23:07
sitebuilderMichael Dunn30-Jun-06 23:07 
Questionabout powerpoint reader Pin
xiahuang11929-Jun-06 17:49
xiahuang11929-Jun-06 17:49 
QuestionEnhance pointer precision Pin
coolice200229-Jun-06 8:27
coolice200229-Jun-06 8:27 
QuestionRe: Enhance pointer precision Pin
Jun Du29-Jun-06 9:11
Jun Du29-Jun-06 9:11 
QuestionRe: Enhance pointer precision [modified] Pin
coolice200229-Jun-06 20:49
coolice200229-Jun-06 20:49 
Questionhow do i use OpenCV code in windows forums [modified] Pin
zamco28-Jun-06 20:59
zamco28-Jun-06 20:59 
AnswerRe: how do i use OpenCV code in windows forums Pin
zamco29-Jun-06 15:59
zamco29-Jun-06 15:59 
QuestionQuestion about MC++ Marshall LParam to Struct Pin
ScottLeff26-Jun-06 10:38
ScottLeff26-Jun-06 10:38 
Hey eveybody,

I have written a WndProc() function that detects the insert and removal of a USB drive and
want to pull out the specific LParam values to get the name of the drive and other info.
The examples I've found so far use a particular C# code that goes like this...

<br />
[StructLayout(LayoutKind.Sequential)]<br />
public struct DEV_BROADCAST_VOLUME<br />
{<br />
    public int dbcv_size;<br />
    public int dbcv_devicetype;<br />
    public int dbcv_reserved;<br />
    public int dbcv_unitmask;<br />
}<br />
protected override void WndProc(ref Message m)<br />
{<br />
    const int WM_DEVICECHANGE = 0x0219;<br />
    const int DBT_DEVICEARRIVAL = 0x8000; // system detected a new device<br />
    const int DBT_DEVTYP_VOLUME = 0x00000002; // logical volume<br />
    //we detect the media arrival event<br />
    if (m.Msg == WM_DEVICECHANGE && m.WParam.ToInt32() == DBT_DEVICEARRIVAL)<br />
    {<br />
        int devType = Marshal.ReadInt32(m.LParam,4);<br />
        if(devType == DBT_DEVTYP_VOLUME)<br />
        {<br />
            DEV_BROADCAST_VOLUME vol;<br />
            vol = (DEV_BROADCAST_VOLUME) Marshal.PtrToStructure(m.LParam,typeof(DEV_BROADCAST_VOLUME));<br />
            MessageBox.Show(vol.dbcv_unitmask.ToString("x"));<br />
        }<br />
    }<br />
    base.WndProc (ref m);<br />
}<br />


And I've been trying to get the LParam into my structure like this:

<br />
__gc struct Volume<br />
{<br />
   int size;<br />
   int devicetype;<br />
   int reserved;<br />
   int unitmask;<br />
}<br />
<br />
protected: void WndProc(System::Windows::Forms::Message* message)	<br />
{<br />
   ...<br />
   if(message->Msg == WM_DEVICECHANGE)<br />
   {<br />
      if(message->WParam == DBT_DEVICEARRIVAL)<br />
      {<br />
	 lVolume = (Volume*)Marshal::PtrToStructure(message->LParam,__typeof(Volume));<br />
						<br />
	 String* str = MaskToLogicalPaths(lVolume->Mask);<br />
	 this->m_FoundBox->Text = String::Format("Plugged In: {0}",str);<br />
      }<br />
      else <br />
      if(message->WParam == DBT_DEVICEREMOVECOMPLETE)<br />
      {<br />
	 this->m_FoundBox->Text = String::Format("UnPlugged: {0}",message->WParam.ToString());<br />
      }                <br />
   }<br />
}<br />


This continues to not work in MC++.
For some reason I cannot find a viable alternative to the C# code in MC++. My errors include
the dreaded run-time:
"The specified structure must be blittable or have layout information..."
among other more standard compile errors for instantiating the structure incorrectly.
I know theres a way to do this but havent found it yet.
Any help you all could be would be greatly appreciated!

ScottLeff
sleff@yahoo.com
Question"Force file output" option in Visual Studio.NET Pin
dashprasannajit25-Jun-06 18:38
dashprasannajit25-Jun-06 18:38 
Questionproblem Facing with c++/cli arrays Pin
Nagaraju_Focus23-Jun-06 21:07
Nagaraju_Focus23-Jun-06 21:07 
AnswerRe: problem Facing with c++/cli arrays Pin
2bee 23-Jun-06 22:02
2bee 23-Jun-06 22:02 
Questionhelp me to create joystick controller Pin
nyquisttt23-Jun-06 4:07
nyquisttt23-Jun-06 4:07 
AnswerRe: help me to create joystick controller Pin
John M. Drescher23-Jun-06 4:37
John M. Drescher23-Jun-06 4:37 
GeneralRe: help me to create joystick controller Pin
nyquisttt26-Jun-06 21:56
nyquisttt26-Jun-06 21:56 
GeneralRe: help me to create joystick controller Pin
Jun Du27-Jun-06 7:11
Jun Du27-Jun-06 7:11 
GeneralRe: help me to create joystick controller Pin
mertadin16-Jul-06 23:12
mertadin16-Jul-06 23:12 
QuestionPointer Syntax Pin
Jay0322-Jun-06 6:02
Jay0322-Jun-06 6:02 
AnswerRe: Pointer Syntax Pin
toxcct22-Jun-06 6:14
toxcct22-Jun-06 6:14 
GeneralRe: Pointer Syntax Pin
Jay0322-Jun-06 8:07
Jay0322-Jun-06 8:07 
Questionhow to __pin my pointer? Pin
sg066721-Jun-06 23:13
sg066721-Jun-06 23:13 
QuestionC2871 using mixed-mode DLL Pin
MChimley21-Jun-06 3:29
MChimley21-Jun-06 3:29 
AnswerRe: C2871 using mixed-mode DLL Pin
Milton Karimbekallil21-Jun-06 7:59
Milton Karimbekallil21-Jun-06 7:59 
GeneralRe: C2871 using mixed-mode DLL Pin
MChimley21-Jun-06 23:19
MChimley21-Jun-06 23:19 
QuestionC++ wrapper for .net assembly Pin
NikoTanghe20-Jun-06 22:41
NikoTanghe20-Jun-06 22:41 
AnswerRe: C++ wrapper for .net assembly Pin
Milton Karimbekallil21-Jun-06 7:55
Milton Karimbekallil21-Jun-06 7:55 

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.