ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Useful Functions(1)

Useful Functions(1)

原创 Linux操作系统 作者:Burgess_Liu 时间:2008-09-06 22:01:57 0 删除 编辑
How to catch UserName and Version? How to play audio file from special folder? You can benefit from blow code.

To get user's IDof current computer
using System.Security.Principal;
WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
txtUserName.Text = wp.Identity.Name.Substring(wp.Identity.Name.IndexOf(@"\") + 1);

To get current version:
using System.Diagnostics;
public static string GetVersion()
{
      FileVersionInfo fvi = FileVersionInfo.GetVersionInfo("MySystem.exe");
      return "System version ( " + fvi.FileVersion + " )";
}

To play audio file from special folder:
using System.Windows.Forms;
[System.Runtime.InteropServices.DllImport("winmm.dll", SetLastError = true)]
static extern bool PlaySound(string pszSound, System.UIntPtr hmod, uint fdwSound);
public static void play(string strFileName)
{
      string strSoundPath = Application.StartupPath.Replace("bin", "WH").Replace("Debug", "Sound") + "\\";
      PlaySound(strSoundPath+strFileName, UIntPtr.Zero, 0);
}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/15053694/viewspace-442173/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: SQLHelper
请登录后发表评论 登录
全部评论

注册时间:2008-09-05

  • 博文量
    19
  • 访问量
    13994