Click here to Skip to main content
15,923,006 members
Home / Discussions / C#
   

C#

 
GeneralRe: Getting bitmap data from System.Windows.Shapes object Pin
AmitDey6-Aug-08 6:47
AmitDey6-Aug-08 6:47 
GeneralRe: Getting bitmap data from System.Windows.Shapes object Pin
Mark Salsbery6-Aug-08 7:07
Mark Salsbery6-Aug-08 7:07 
GeneralRe: Getting bitmap data from System.Windows.Shapes object Pin
AmitDey6-Aug-08 7:17
AmitDey6-Aug-08 7:17 
GeneralRe: Getting bitmap data from System.Windows.Shapes object Pin
led mike6-Aug-08 7:26
led mike6-Aug-08 7:26 
QuestionAccessViolationException - mciGetErrorString - DllImport("winmm.dll") [modified] Pin
Steven D. Foster6-Aug-08 5:17
Steven D. Foster6-Aug-08 5:17 
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 
Yep, you guys were right on. The C++ to C# conventions types threw me a bit off. TY TY.

Now... You wouldn't have any idea why I can make winmm.dll MCI device calls from a windows forms app but not a console app? I believe a windows forms app uses the default sound device, but the console app attempts to use it (the default one windows is probably holding onto) and windows tells it...
"Unknown problem while loading the specified device driver."

This error shows up regardless if the audio file path is valid or not.

I would think the windows console process would have access to the windows audio devices.

I used the final code below to generate the error. Works in a form app, not in a console app.
VS 2005, and C# 2008.


Any ideas?


Code is as follows...

class Program
{
    [System.Runtime.InteropServices.DllImport("winmm.dll", EntryPoint = "mciGetErrorString")]
    public static extern bool mciGetErrorString(int dwError, StringBuilder lpstrBuffer, int uLength);

    [System.Runtime.InteropServices.DllImport("winmm.dll")]
    private static extern int mciSendString(string strCommand, string strReturn, int iReturnLength, IntPtr hwndCallback);

    static void Main(string[] args)
    {
        string Pcommand = "open \"" + "C:\\SomeNonExistantFile.mp3" + "\" type mpegvideo alias MediaFile";
        int err = mciSendString(Pcommand, null, 0, IntPtr.Zero);
        StringBuilder text = new StringBuilder(128, 128);

        mciGetErrorString(err, text, int.MaxValue);
        Console.WriteLine(text);

        Console.WriteLine();
        Console.WriteLine("Press Any Key");
        Console.ReadKey();
    }
}

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 
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 

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.