utilities.cs
来自「功能:基于windows mobile 的地图查看器。使用vs2005开发」· CS 代码 · 共 40 行
CS
40 行
using System;
using System.Runtime.InteropServices;
namespace PInvokeLibrary
{
/// <summary>
/// Summary description for Utilities.
/// </summary>
public class Utilities
{
/// <summary>
/// Convert a string to an allocated character array.
/// </summary>
/// <param name="s">string to be converted</param>
/// <returns>Location of allocated character array</returns>
public static IntPtr StringToHLocalUni(string s)
{
if (s == null)
{
return IntPtr.Zero;
}
else
{
int nc = s.Length;
uint len = (uint)(2 * (1 + nc));
IntPtr hLocal = Memory.LocalAlloc(Memory.LMEM_FIXED,len);
if (hLocal == IntPtr.Zero)
{
throw new OutOfMemoryException();
}
else
{
Marshal.Copy(s.ToCharArray(), 0, hLocal, s.Length);
return hLocal;
}
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?