请资助汉化工作.
相对路径
.NET Compact Framework 提供了Directory.GetCurrentDirectory Method 取当前运行文件的目录,可是运行的时候会抛出 NotSupportedException 。
替代方案使用 Path.GetDirectoryName Method 和 AssemblyName.CodeBase Property 来代替。
当前运行路径
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName);
.NET Compact Framework 提供了Directory.GetCurrentDirectory Method 取当前运行文件的目录,可是运行的时候会抛出 NotSupportedException 。
替代方案使用 Path.GetDirectoryName Method 和 AssemblyName.CodeBase Property 来代替。
当前运行路径
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
首先,我们建立一个.net cf 2.0下,名称为SoundPlay的WM5 ppc项目,当然语言我选择的是C#。
然后界面设计如下:其中:
lblFileName——Text属性:文件地址
btnOpen——Text属性:浏览文件
btnPlay——Text属性:播放声音
新建一个类:Sound,代码和小镇的差不多,不过我做过一小点修改,所以也贴出来,方便大家查阅:
using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Collections.Generic;
using System.Text;
namespace SoundPlay
{
public class Sound
{
private byte[] m_soundBytes;
private enum Flags
{
SND_SYNC = 0x0000, /* play synchronously (default) */
SND_ASYNC = 0x0001, /* play asynchronously */
SND_NODEFAULT = 0x0002, /* silence (!default) if sound not found */
SND_MEMORY = 0x0004, /* pszSound points to a memory file */
SND_LOOP = 0x0008, /* loop the sound until next sndPlaySound */
SND_NOSTOP = 0x0010, /* don't stop any currently playing sound */
SND_NOWAIT = 0x00002000, /* don't wait if the driver is busy */
SND_ALIAS = 0x00010000, /* name is a registry alias */
SND_ALIAS_ID = 0x00110000, /* alias is a predefined ID */
SND_FILENAME = 0x00020000, /* name is file name */
SND_RESOURCE = 0x00040004 /* name is resource name or atom */
}
[DllImport("CoreDll.DLL", EntryPoint = "PlaySound", SetLastError = true)]
private extern static int MobilePlaySound(string szSound, IntPtr hMod, int flags);//播放外部声音文件
[DllImport("CoreDll.DLL", EntryPoint = "PlaySound", SetLastError = true)]
private extern static int MoiblePlaySoundBytes(byte[] szSound, IntPtr hMod, int flags);//播放嵌入声音资源
/// <summary>
/// Construct the Sound object to play sound data from the specified stream.
/// </summary>
public Sound(Stream stream)
{
// read the data from the stream
m_soundBytes = new byte[stream.Length];
stream.Read(m_soundBytes, 0, (int)stream.Length);
}
/// <summary>
/// 从一个声音byte流构造函数Sound
/// </summary>
/// <param name="snd"></param>
public Sound(byte[] snd)
{
m_soundBytes = snd;
}
/// <summary>
/// 构造一个空Sound函数,此函数用于播放外部文件
/// </summary>
public Sound()
{
}
/// <summary>
/// Play the sound File播放外部文件的Play方法
/// </summary>
public void Play(string filename)
{
MobilePlaySound(filename, IntPtr.Zero, (int)(Flags.SND_ASYNC | Flags.SND_FILENAME));
}
/// <summary>
/// Play The Stream Sound,此方法应该对应从Byte和Stream构造的Sound
/// 注意,它的Flags设置为SND_MEMORY,因为我们的声音文件已经转换到内存中了
/// </summary>
public void Play()
{
MoiblePlaySoundBytes(m_soundBytes, IntPtr.Zero, (int)(Flags.SND_ASYNC | Flags.SND_MEMORY));
}
}
}
然后,主界面上的按钮事件代码如下:
private void btnOpen_Click(object sender, EventArgs e)
{
using (OpenFileDialog ofd = new OpenFileDialog())
{
if (ofd.ShowDialog() == DialogResult.OK)
{
lblFileName.Text = ofd.FileName;
}
}
}
private void btnPlay_Click(object sender, EventArgs e)
{
Sound sound = new Sound();
sound.Play(lblFileName.Text);
}
名称:移除快捷键小箭头 Ver0.2
来自:www.ppcqq.com
说明:
安全支持Vista、Windows 7以及后续版本,移除快捷键小箭头
特别说明:本软件用了UPX进行了体积压缩,可能引起误杀
版本:
Ver 0.2:修正绝对路径

下载文件 (已下载 41 次)
来自:www.ppcqq.com
说明:
安全支持Vista、Windows 7以及后续版本,移除快捷键小箭头
特别说明:本软件用了UPX进行了体积压缩,可能引起误杀
版本:
Ver 0.2:修正绝对路径
下载文件 (已下载 41 次)
隔了很长时间没有碰Delphi,就连最最基本都忘光了!看来“温故而知新”、“学如逆水行舟,不进则退”是有绝对的道理!
就这获取路径的东西,都折腾了很久,是自己忘光了?还是自己大意呢?
不是忘记使用USE SHELLAPI,几时缺少字母,哎。。。。瞎折腾
use shellapi
procedure TForm1.Button1Click(Sender: TObject);
var
adr: array[0..MAX_PATH] of Char;
begin
GetSystemDirectory(adr,MAX_PATH); //获取SYSTEM路径
//GetWindowsDirectory(adr,MAX_PATH); //获取WINDOWSM路径
ShowMessage(adr); //显示C:\Windows\System32
end;
就这获取路径的东西,都折腾了很久,是自己忘光了?还是自己大意呢?
不是忘记使用USE SHELLAPI,几时缺少字母,哎。。。。瞎折腾
use shellapi
procedure TForm1.Button1Click(Sender: TObject);
var
adr: array[0..MAX_PATH] of Char;
begin
GetSystemDirectory(adr,MAX_PATH); //获取SYSTEM路径
//GetWindowsDirectory(adr,MAX_PATH); //获取WINDOWSM路径
ShowMessage(adr); //显示C:\Windows\System32
end;







