Click here to Skip to main content
16,005,038 members
Home / Discussions / C#
   

C#

 
GeneralRe: OCX Control .NET Heath Can you help? Pin
Heath Stewart2-Apr-04 11:00
protectorHeath Stewart2-Apr-04 11:00 
GeneralStill fails in C# Pin
sbeausol2-Apr-04 11:18
sbeausol2-Apr-04 11:18 
GeneralRe: Still fails in C# Pin
Heath Stewart3-Apr-04 3:14
protectorHeath Stewart3-Apr-04 3:14 
GeneralRe: Still fails in C# Pin
sbeausol3-Apr-04 6:17
sbeausol3-Apr-04 6:17 
GeneralRe: save datagrid Pin
Heath Stewart1-Apr-04 5:11
protectorHeath Stewart1-Apr-04 5:11 
GeneralRe: save datagrid Pin
bertcox1-Apr-04 5:35
bertcox1-Apr-04 5:35 
GeneralRe: save datagrid Pin
Heath Stewart1-Apr-04 5:56
protectorHeath Stewart1-Apr-04 5:56 
GeneralInterop Question. Again... Pin
DrGreen1-Apr-04 3:15
DrGreen1-Apr-04 3:15 
Hi,

Sorry for bringing this again, but I'm having a little problem with C# and Interop.

I want to use mciSendCommand function and a few structures associated with it in C#. I'm declaring this:

<br />
private static UInt32 MCI_OPEN = 0x0803;<br />
private static UInt32 MCI_CLOSE = 0x0804;<br />
<br />
private static ulong MCI_OPEN_SHAREABLE = 0x00000100L;<br />
private static ulong MCI_OPEN_ELEMENT = 0x00000200L;<br />
private static ulong MCI_OPEN_ALIAS = 0x00000400L;<br />
private static ulong MCI_OPEN_ELEMENT_ID = 0x00000800L;<br />
private static ulong MCI_OPEN_TYPE_ID = 0x00001000L;<br />
private static ulong MCI_OPEN_TYPE = 0x00002000L;<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
internal class MCI_OPEN_PARMS<br />
{<br />
        public UInt32	dwCallback; <br />
	public UInt32   wDeviceID; <br />
	[MarshalAs(UnmanagedType.LPStr)]<br />
	public String	lpstrDeviceType;<br />
	[MarshalAs(UnmanagedType.LPStr)]<br />
	public String	lpstrElementName; <br />
	[MarshalAs(UnmanagedType.LPStr)]<br />
	public String	lpstrAlias; <br />
}<br />
<br />
[DllImportAttribute("Winmm.dll")]<br />
protected extern static UInt32 mciSendCommand(UInt32 IDDevice, UInt32 uMsg, ulong fdwCommand, [Out] IntPtr dwParam);<br />


And the I use that like this:

<br />
MCI_OPEN_PARMS openParms = new MCI_OPEN_PARMS();<br />
<br />
openParms.lpstrDeviceType = "cdaudio";<br />
openParms.lpstrElementName = "F:\"<br />
<br />
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(openParms));<br />
Marshal.StructureToPtr(openParms, ptr, false);<br />
<br />
error = mciSendCommand(0, MCI_OPEN, MCI_OPEN_SHAREABLE | MCI_OPEN_TYPE | MCI_OPEN_ELEMENT, ptr);<br />


When mciSendCommand executes one exception is thrown with the following message: "Object Reference not set to an instance of an object."

I think the problem is in ptr variable, maybe because it's where the function returns it's data.

What am I doing wrong?

I'm sorry for this long topic. Smile | :)

Thanks,

Pedro
GeneralRe: Interop Question. Again... Pin
Dave Kreskowiak1-Apr-04 3:41
mveDave Kreskowiak1-Apr-04 3:41 
GeneralRe: Interop Question. Again... Pin
DrGreen1-Apr-04 3:57
DrGreen1-Apr-04 3:57 
GeneralRe: Interop Question. Again... Pin
Dave Kreskowiak1-Apr-04 4:11
mveDave Kreskowiak1-Apr-04 4:11 
GeneralRe: Interop Question. Again... Pin
Heath Stewart1-Apr-04 5:39
protectorHeath Stewart1-Apr-04 5:39 
GeneralRe: Interop Question. Again... Pin
DrGreen1-Apr-04 6:06
DrGreen1-Apr-04 6:06 
GeneralRe: Interop Question. Again... Pin
Heath Stewart1-Apr-04 6:23
protectorHeath Stewart1-Apr-04 6:23 
GeneralRe: Interop Question. Again... Pin
DrGreen1-Apr-04 6:33
DrGreen1-Apr-04 6:33 
GeneralRe: Interop Question. Again... Pin
leppie1-Apr-04 6:17
leppie1-Apr-04 6:17 
GeneralRe: Interop Question. Again... Pin
Heath Stewart1-Apr-04 6:30
protectorHeath Stewart1-Apr-04 6:30 
GeneralRe: Interop Question. Again... Pin
leppie1-Apr-04 6:10
leppie1-Apr-04 6:10 
GeneralRe: Interop Question. Again... Pin
DrGreen1-Apr-04 6:20
DrGreen1-Apr-04 6:20 
GeneralC# listbox, combobox trouble Pin
abidkayani11-Apr-04 2:49
abidkayani11-Apr-04 2:49 
GeneralC # problem (app block) Pin
abidkayani11-Apr-04 2:43
abidkayani11-Apr-04 2:43 
GeneralRe: C # problem (app block) Pin
Mazdak1-Apr-04 2:59
Mazdak1-Apr-04 2:59 
GeneralRe: C # problem (app block) Pin
abidkayani11-Apr-04 12:15
abidkayani11-Apr-04 12:15 
GeneralC# problem Pin
abidkayani11-Apr-04 2:41
abidkayani11-Apr-04 2:41 
GeneralRe: C# problem Pin
Mazdak1-Apr-04 2:54
Mazdak1-Apr-04 2:54 

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.