大家好啊,向大家请教个问题,在XP系统中用什么工具阅读从PDA(CE5.0系统)抓取的图片?用下面的方法在PDA里面运行exe文件,进行抓图using System.Drawing.Imaging;
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern bool BitBlt(
IntPtr hdcDest, //目标设备的句柄
int nXDest, // 目标对象的左上角的X坐标
int nYDest, // 目标对象的左上角的X坐标
int nWidth, // 目标对象的矩形的宽度
int nHeight, // 目标对象的矩形的长度
IntPtr hdcSrc, // 源设备的句柄
int nXSrc, // 源对象的左上角的X坐标
int nYSrc, // 源对象的左上角的X坐标
System.Int32 dwRop // 光栅的操作值
); [System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern IntPtr CreateDC(
string lpszDriver, // 驱动名称
string lpszDevice, // 设备名称
string lpszOutput, // 无用,可以设定位"NULL"
IntPtr lpInitData // 任意的打印机数据
); private void button1_Click(object sender, EventArgs e)
{
this.Hide();
IntPtr dc1 = CreateDC("DISPLAY", null, null, (IntPtr)null);
//创建显示器的DC
Graphics g1 = Graphics.FromHdc(dc1);
//由一个指定设备的句柄创建一个新的Graphics对象
Bitmap MyImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, g1);
//根据屏幕大小创建一个与之相同大小的Bitmap对象
Graphics g2 = Graphics.FromImage(MyImage);
//获得屏幕的句柄
IntPtr dc3 = g1.GetHdc();
//获得位图的句柄
IntPtr dc2 = g2.GetHdc();
//把当前屏幕捕获到位图对象中
BitBlt(dc2, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, dc3, 0, 0, 13369376);
//把当前屏幕拷贝到位图中
g1.ReleaseHdc(dc3);
//释放屏幕句柄
g2.ReleaseHdc(dc2);
//释放位图句柄 Bitmap img = new Bitmap(MyImage, 800, 600);
//缩放图片到800*600
img.Save("d:\\MyJpeg.jpg", ImageFormat.Jpeg);
MessageBox.Show("已经把当前屏幕保存到C:\\MyJpeg.jpg文件中!");
this.Show();
}
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern bool BitBlt(
IntPtr hdcDest, //目标设备的句柄
int nXDest, // 目标对象的左上角的X坐标
int nYDest, // 目标对象的左上角的X坐标
int nWidth, // 目标对象的矩形的宽度
int nHeight, // 目标对象的矩形的长度
IntPtr hdcSrc, // 源设备的句柄
int nXSrc, // 源对象的左上角的X坐标
int nYSrc, // 源对象的左上角的X坐标
System.Int32 dwRop // 光栅的操作值
); [System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern IntPtr CreateDC(
string lpszDriver, // 驱动名称
string lpszDevice, // 设备名称
string lpszOutput, // 无用,可以设定位"NULL"
IntPtr lpInitData // 任意的打印机数据
); private void button1_Click(object sender, EventArgs e)
{
this.Hide();
IntPtr dc1 = CreateDC("DISPLAY", null, null, (IntPtr)null);
//创建显示器的DC
Graphics g1 = Graphics.FromHdc(dc1);
//由一个指定设备的句柄创建一个新的Graphics对象
Bitmap MyImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, g1);
//根据屏幕大小创建一个与之相同大小的Bitmap对象
Graphics g2 = Graphics.FromImage(MyImage);
//获得屏幕的句柄
IntPtr dc3 = g1.GetHdc();
//获得位图的句柄
IntPtr dc2 = g2.GetHdc();
//把当前屏幕捕获到位图对象中
BitBlt(dc2, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, dc3, 0, 0, 13369376);
//把当前屏幕拷贝到位图中
g1.ReleaseHdc(dc3);
//释放屏幕句柄
g2.ReleaseHdc(dc2);
//释放位图句柄 Bitmap img = new Bitmap(MyImage, 800, 600);
//缩放图片到800*600
img.Save("d:\\MyJpeg.jpg", ImageFormat.Jpeg);
MessageBox.Show("已经把当前屏幕保存到C:\\MyJpeg.jpg文件中!");
this.Show();
}
我就是想实现:在CE5.0 下写一个程序,拷贝到PDA里面,
抓取图片以后暂时存储在PDA里面,
然后再拷贝到电脑里面用别的图片处理工具来读图片;
上面的那个截图不知道是否可以在PDA里面运行
C#代码
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern int CeCloseHandle(IntPtr hObject);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern int CeCopyFile(string lpExistingFileName, string lpNewFileName, int bFailIfExists);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern int CeCreateDirectory(string lpPathName, uint lpSecurityAttributes);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern IntPtr CeCreateFile(string lpFileName, uint dwDesiredAccess, int dwShareMode, int lpSecurityAttributes, int dwCreationDisposition, int dwFlagsAndAttributes, int hTemplateFile);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int CeCreateProcess(string pszImageName, IntPtr pszCmdLine, IntPtr psaProcess, IntPtr psaThread, int fInheritHandles, int fdwCreate, IntPtr pvEnvironment, IntPtr pszCurDir, IntPtr psiStartInfo, out PROCESS_INFORMATION pi);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int CeCreateProcess(string pszImageName, string pszCmdLine, IntPtr psaProcess, IntPtr psaThread, int fInheritHandles, int fdwCreate, IntPtr pvEnvironment, IntPtr pszCurDir, IntPtr psiStartInfo, out PROCESS_INFORMATION pi);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern int CeDeleteFile(string lpFileName);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int CeFindClose(IntPtr hFindFile);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern IntPtr CeFindFirstFile(string lpFileName, byte[] lpFindFileData);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int CeFindNextFile(IntPtr hFindFile, byte[] lpFindFileData);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int CeGetDesktopDeviceCaps(int nIndex);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern uint CeGetFileAttributes(string lpFileName);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern uint CeGetFileSize(IntPtr hFile, ref uint lpFileSizeHigh);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern int CeGetFileTime(IntPtr hFile, ref long lpCreationTime, ref long lpLastAccessTime, ref long lpLastWriteTime);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int CeGetLastError();
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int CeGetSpecialFolderPath(int nFolder, uint nBufferLength, StringBuilder lpBuffer);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int CeGetStoreInformation(out STORE_INFORMATION lpsi);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int CeGetSystemInfo(out SYSTEM_INFO pSI);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern bool CeGetSystemPowerStatusEx(out SYSTEM_POWER_STATUS_EX pStatus, bool fUpdate);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern bool CeGetVersionEx(out OSVERSIONINFO lpVersionInformation);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern void CeGlobalMemoryStatus(out MEMORYSTATUS msce);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern int CeMoveFile(string lpExistingFileName, string lpNewFileName);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern int CeRapiGetError();
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern int CeRapiInit();
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern int CeRapiInitEx([MarshalAs(UnmanagedType.Struct)] ref RAPIINIT pRapiInit);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int CeRapiInvoke(string pDllPath, string pFunctionName, uint cbInput, IntPtr pInput, out uint pcbOutput, out IntPtr ppOutput, IntPtr ppIRAPIStream, uint dwReserved);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern int CeRapiUninit();
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int CeReadFile(IntPtr hFile, byte[] lpBuffer, int nNumberOfbytesToRead, ref int lpNumberOfbytesRead, int lpOverlapped);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern int CeRemoveDirectory(string lpPathName);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int CeSetEndOfFile(int hFile);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern int CeSetFileAttributes(string lpFileName, uint dwFileAttributes);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern int CeSetFileTime(IntPtr hFile, ref long lpCreationTime, ref long lpLastAccessTime, ref long lpLastWriteTime);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int CeSHCreateShortcut(string pShortcutName, string pTarget);
[DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]
internal static extern int CeSHGetShortcutTarget(string lpszShortcut, string lpszTarget, int cbMax);
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
internal static extern int CeWriteFile(IntPtr hFile, byte[] lpBuffer, int nNumberOfbytesToWrite, ref int lpNumberOfbytesWritten, int lpOverlapped);