/// <summary> /// 获取打印机驱动名称 /// </summary> /// <param name="printname"></param> /// <returns></returns> public static string GetPrintDirName(string printname) { uint pcbNeeded = 0; uint pcReturne = 0; var pAddr = Marshal.AllocHGlobal((int)pcbNeeded); var ret = WinApiHepler.EnumPrintersA(PrinterEnumFlags.PrinterEnumLocal, null, 2, pAddr, pcbNeeded, ref pcbNeeded, ref pcReturne); if (!ret) { return(""); } var info2 = new PrintDeviceStruct.PrinterInfo2[pcReturne]; var offset = pAddr.ToInt32(); var temp = string.Empty; for (var i = 0; i < pcReturne; i++) { info2[i] = (PrintDeviceStruct.PrinterInfo2) Marshal.PtrToStructure(new IntPtr(offset), typeof(PrintDeviceStruct.PrinterInfo2)); offset += Marshal.SizeOf(typeof(PrintDeviceStruct.PrinterInfo2)); if (info2[i].pPrinterName == printname) { temp = info2[i].pDriverName; } } return(temp); }
/// <summary> /// 内存释放 /// </summary> public static void FlushMemory() { GC.Collect(); GC.WaitForPendingFinalizers(); if (Environment.OSVersion.Platform == PlatformID.Win32NT) { WinApiHepler.SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1); } }
/// <summary> /// INI读取 使用前先调用void Ini 赋值路径 /// </summary> /// <param name="section">配置节</param> /// <param name="key">键名</param> /// <returns>返回读取值</returns> public string ReadValue(string section, string key) { // 每次从ini中读取多少字节 StringBuilder temp = new StringBuilder(255); // section=配置节,key=键名,temp=上面,path=路径 WinApiHepler.GetPrivateProfileString(section, key, "", temp, 255, InIsPath); return(temp.ToString()); }
private void Errorlog(int error) { var errorText = new StringBuilder(50); WinApiHepler.mciGetErrorString(error, errorText, errorText.Capacity); if (EventAudioplayerror == null) { return; } EventAudioplayerror(errorText.ToString()); }
public AudioModel(string file, string alias, object data) { PlayFile = file; AliasMovie = alias; SourceData = data; FileName = System.IO.Path.GetFileNameWithoutExtension(file); var shortpath = new StringBuilder(255); WinApiHepler.GetShortPathName(PlayFile, shortpath, shortpath.Capacity); ShortPath = shortpath.ToString(); }
/// <summary> /// INI读取预设值比较返回true false /// </summary> /// <param name="section">配置节</param> /// <param name="key">键名</param> /// <param name="comparedvalue">预设值</param> /// <returns>返回bool</returns> public bool ReadValue(string section, string key, string comparedvalue) { // 每次从ini中读取多少字节 StringBuilder temp = new StringBuilder(255); // section=配置节,key=键名,temp=上面,path=路径 WinApiHepler.GetPrivateProfileString(section, key, "", temp, 255, InIsPath); if (temp.ToString() != comparedvalue) { return(false); } return(true); }
/// <summary> /// 执行指令 /// </summary> /// <param name="order">指令</param> /// <param name="returnString">需要返回的数据</param> /// <param name="returnsize">返回数据大小</param> /// <returns></returns> private bool DoOrder(string order, StringBuilder returnString, int returnsize) { var error = WinApiHepler.mciSendString(order, returnString, returnsize, new IntPtr()); if (IsDisplsed) { return(false); } if (error == 0) { return(true); } Errorlog(error); return(false); }
/// <summary> /// INI写入 使用前先调用void Ini 赋值路径 /// </summary> /// <param name="section">配置节</param> /// <param name="key">键名</param> /// <param name="value">值</param> public void Write(string section, string key, string value) { // section=配置节,key=键名,value=键值,path=路径 WinApiHepler.WritePrivateProfileString(section, key, value, InIsPath); }
/// <summary> /// 设置默认打印机 /// </summary> /// <param name="name">打印机名称</param> /// <returns></returns> public static bool SettingDefaultPrinter(string name) { return(WinApiHepler.SetDefaultPrinter(name)); }