简体   繁体   中英

C# Console Program Won't Execute from Command Prompt

I have made a very simple program in C#. When I double click the compiled exe, it executes and works. When I run the exe from the command prompt, it does absolutely nothing. I have tried executing it from an Administrator command prompt also. I am on Windows 7. This is very frustrating.

The only command the program executes when ran is

SendMessageW(Process.GetCurrentProcess().MainWindowHandle, WM_APPCOMMAND, Process.GetCurrentProcess().MainWindowHandle, (IntPtr)APPCOMMAND_VOLUME_MUTE);

A console program may have no message loop or main window. So SendMessageW() does not work.

Not sure what you are trying to accomplish, but this little program

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(Process.GetCurrentProcess().MainWindowHandle);
        Console.ReadKey();
    }
}

may help you troubleshoot your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM