ApplicationInformation.cs 780 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. namespace XUnity.AutoTranslator.Plugin.Core
  7. {
  8. internal static class ApplicationInformation
  9. {
  10. [DllImport( "kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = false )]
  11. private static extern int GetModuleFileName( HandleRef hModule, StringBuilder buffer, int length );
  12. private static HandleRef Null = new HandleRef( null, IntPtr.Zero );
  13. public static string StartupPath
  14. {
  15. get
  16. {
  17. StringBuilder stringBuilder = new StringBuilder( 260 );
  18. GetModuleFileName( Null, stringBuilder, stringBuilder.Capacity );
  19. return stringBuilder.ToString();
  20. }
  21. }
  22. }
  23. }