Click here to Skip to main content
15,897,518 members
Home / Discussions / C#
   

C#

 
AnswerRe: AccessViolationException - mciGetErrorString - DllImport("winmm.dll") Pin
Steven D. Foster6-Aug-08 5:56
Steven D. Foster6-Aug-08 5:56 
GeneralRe: AccessViolationException - mciGetErrorString - DllImport("winmm.dll") Pin
Jimmanuel6-Aug-08 9:16
Jimmanuel6-Aug-08 9:16 
QuestionRe: AccessViolationException - mciGetErrorString - DllImport("winmm.dll") Pin
Steven D. Foster6-Aug-08 10:03
Steven D. Foster6-Aug-08 10:03 
AnswerRe: AccessViolationException - mciGetErrorString - DllImport("winmm.dll") Pin
Jimmanuel6-Aug-08 10:36
Jimmanuel6-Aug-08 10:36 
QuestionRe: AccessViolationException - mciGetErrorString - DllImport("winmm.dll") Pin
Steven D. Foster6-Aug-08 10:49
Steven D. Foster6-Aug-08 10:49 
AnswerRe: AccessViolationException - mciGetErrorString - DllImport("winmm.dll") Pin
Jimmanuel6-Aug-08 11:02
Jimmanuel6-Aug-08 11:02 
GeneralRe: AccessViolationException - mciGetErrorString - DllImport("winmm.dll") Pin
Steven D. Foster6-Aug-08 11:10
Steven D. Foster6-Aug-08 11:10 
AnswerRe: AccessViolationException - mciGetErrorString - DllImport("winmm.dll") Pin
Mark Salsbery6-Aug-08 9:38
Mark Salsbery6-Aug-08 9:38 
Jimmanuel is right on the money....

You need to use the appropriate types to interop.

DWORDs will never be a C# long - they are always unsigned 32-bit ints.
A BOOL is an int, which is a 32-bit signed int.
As Jimmanuel mentioned, you also can't use a string as an out parameter like that.

Put that all together and something like this should work:
[System.Runtime.InteropServices.DllImport("winmm.dll")]
private static extern int mciGetErrorString(UInt32 errorCode, StringBuilder buffer, UInt32 iReturnLength);

I tested this with the following code and it worked:
StringBuilder sb = new StringBuilder(260);
mciGetErrorString(256+37, sb, 260); //256+37 == MCIERR_BAD_TIME_FORMAT
Console.WriteLine(sb.ToString());



Mark

Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

QuestionHow to trace my Application with Visual Studio? Pin
hdv2126-Aug-08 4:56
hdv2126-Aug-08 4:56 
QuestionI need a Word Viewer Pin
Laji596-Aug-08 4:33
Laji596-Aug-08 4:33 
AnswerRe: I need a Word Viewer Pin
Thomas Stockwell6-Aug-08 4:38
professionalThomas Stockwell6-Aug-08 4:38 
AnswerRe: I need a Word Viewer Pin
Paul Conrad6-Aug-08 5:18
professionalPaul Conrad6-Aug-08 5:18 
AnswerRe: I need a Word Viewer Pin
vikas amin6-Aug-08 8:50
vikas amin6-Aug-08 8:50 
GeneralRe: I need a Word Viewer Pin
vikas amin6-Aug-08 8:52
vikas amin6-Aug-08 8:52 
AnswerRe: I need a Word Viewer Pin
CezW6-Aug-08 9:50
CezW6-Aug-08 9:50 
QuestionVERY STRANGE! what is this regex problem? [modified] Pin
enginço6-Aug-08 4:23
enginço6-Aug-08 4:23 
AnswerRe: VERY STRANGE! what is this regex problem? [modified] Pin
enginço6-Aug-08 4:46
enginço6-Aug-08 4:46 
GeneralRe: VERY STRANGE! what is this regex problem? Pin
Guffa6-Aug-08 8:37
Guffa6-Aug-08 8:37 
QuestionLoad form in the background? Pin
Justin Time6-Aug-08 4:12
Justin Time6-Aug-08 4:12 
AnswerRe: Load form in the background? Pin
DaveyM696-Aug-08 4:21
professionalDaveyM696-Aug-08 4:21 
GeneralRe: Load form in the background? Pin
Frank Horn6-Aug-08 6:48
Frank Horn6-Aug-08 6:48 
QuestionAutomating Internet Explorer using WatIn Pin
Raj-Ekoham DwitiyoNasti6-Aug-08 4:03
Raj-Ekoham DwitiyoNasti6-Aug-08 4:03 
Questionoverride a treenode class Pin
sanjeevmedhi6-Aug-08 3:47
sanjeevmedhi6-Aug-08 3:47 
AnswerRe: override a treenode class Pin
Bardy856-Aug-08 3:58
Bardy856-Aug-08 3:58 
GeneralRe: override a treenode class Pin
sanjeevmedhi6-Aug-08 4:00
sanjeevmedhi6-Aug-08 4:00 

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.