Created
March 25, 2021 08:51
-
-
Save EgorBo/b81454826ff1580441abad90d66bcac3 to your computer and use it in GitHub Desktop.
call-beep.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Runtime.InteropServices; | |
| class Prog | |
| { | |
| static unsafe void Main() | |
| { | |
| var func = (delegate* unmanaged<int, int, int>)GetProcAddress(GetModuleHandle("kernel32.dll"), "Beep"); | |
| int result = func(500, 500); | |
| } | |
| [DllImport("kernel32.dll"), SuppressGCTransition] | |
| static extern IntPtr GetProcAddress(IntPtr hModule, string entryPoint); | |
| [DllImport("kernel32.dll"), SuppressGCTransition] | |
| static extern IntPtr GetModuleHandle(string moduleName); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment