dword(pointer() cursor pointer - 电脑|办公 - 电脑办公-杀毒安全-网络-V3学习网
微商网
 
 
导航:首页 |电脑|办公|正文

dword(pointer() cursor pointer

时间:2020-06-25 14:04:09
delphi的pdword和dword之间的关系问题 tmpval:=dword(value);这句的意思是把value强制转换成dword类型,主要看value是什么类型,如果value是一个指针类
作者:

dword(pointer()

delphi的pdword和dword之间的关系问题

tmpval:=dword(value);这句的意思是把value强制转换成dword类型,主要看value是什么类型,如果value是一个指针类型,那么这句的的意思就是返回指针指向的地址。

pdword(tmpptr)^:=$91这句其实和tmpptr^:=$91一样,因为tmpptr本来就是pdword类型的指针,如果tmpptr是无类型指针(pointer)才需要这样转换一下。

象这样的类型Delphi还有很多,比如String和PString,Integer和PInteger等,当然你也可以自己定义

怎么处理SendMessage()发来的消息

1. 在类的声明处加入afx_msg打头的消息响应函数声明。

2.在cpp文件中实现该函数(参数依据你自己的设计,WPARAM和LPARAM都能传递数据,不用也可)。

3.在该类的DECLARE_MESSAGE_MAP与END_MESSAGE_MAP之间插入ON_MESSAGE(消息名,函数名)。

消息本身是作为一个记录传递给应用程序的,这个记录中包含了消息的类型以及其他信息。

例如,对于单击鼠标所产生的消息来说,这个记录中包含了单击鼠标时的坐标。

这个记录类型叫做TMsg,它在Windows单元中是这样声明的: type TMsg = packed record hwnd: HWND; //窗口句柄 message: UINT;//消息常量标识符 wParam: WPARAM ;// 32位消息的特定附加信息 lParam: LPARAM ;// 32位消息的特定附加信息 time: DWORD;//消息创建时的时间 pt: TPoint; //消息创建时的鼠标位置 end ; 消息中有什么? 是否觉得一个消息记录中的信息像希腊语一样?如果是这样,那么看一看下面的解释:hwnd 32位的窗口句柄。

窗口可以是任何类型的屏幕对象,因为Win32能够维护大多数可 视对象的句柄(窗口、对话框、按钮、编辑框等)。

message 用于区别其他消息的常量值,这些常量可以是Windows单元中预定义的常量,也 可以是自定义的常量。

wParam 通常是一个与消息有关的常量值,也可能是窗口或控件的句柄。

lParam 通常是一个指向内存中数据的指针。

由于WParam、lParam和Pointer都是32位的,因此,它们之间可以相互转换。

00405EB0 mov eax,dword ptr [ecx] 是什么意思?

跨进程获得RichEdit Text参考:Delphi(Pascal) codeuses RichEdit;function Process_ReadRichEditText(AHandle: THandle): WideString;var vGetTextEx: GETTEXTEX; vGetTextLengthEx: GETTEXTLENGTHEX; L: Integer; vProcessId: DWORD; vProcess: THandle; vPointer: Pointer; vNumberOfBytesRead: Cardinal;begin Result := ""; if not IsWindow(AHandle) then Exit; GetWindowThreadProcessId(AHandle, @vProcessId); vProcess := OpenProcess(PROCESS_VM_OPERATION or PROCESS_VM_READ or PROCESS_VM_WRITE, False, vProcessId); try vPointer := VirtualAllocEx(vProcess, nil, 4096, MEM_RESERVE or MEM_COMMIT, PAGE_READWRITE); try vGetTextLengthEx.flags := GTL_DEFAULT; vGetTextLengthEx.codepage := 1200; // Unicode WriteProcessMemory(vProcess, vPointer, @vGetTextLengthEx, SizeOf(vGetTextLengthEx), vNumberOfBytesRead); L := SendMessage(AHandle, EM_GETTEXTLENGTHEX, Integer(vPointer), 0); finally VirtualFreeEx(vProcess, vPointer, 0, MEM_RELEASE); end; if L vPointer := VirtualAllocEx(vProcess, nil, SizeOf(vGetTextEx) + L * 2 + 2, MEM_RESERVE or MEM_COMMIT, PAGE_READWRITE); try SetLength(Result, L); vGetTextEx.cb := L * 2 + 2; // 加上结束符号 vGetTextEx.flags := GT_DEFAULT; vGetTextEx.codepage := 1200; // Unicode vGetTextEx.lpDefaultChar := nil; vGetTextEx.lpUsedDefChar := nil; WriteProcessMemory(vProcess, vPointer, @vGetTextEx, SizeOf(vGetTextEx), vNumberOfBytesRead); SendMessage(AHandle, EM_GETTEXTEX, Integer(vPointer), Integer(vPointer) + SizeOf(vGetTextEx)); ReadProcessMemory(vProcess, Pointer(Integer(vPointer) + SizeOf(vGetTextEx)), @Result[1], L * 2, vNumberOfBytesRead); finally VirtualFreeEx(vProcess, vPointer, 0, MEM_RELEASE); end; finally CloseHandle(vProcess); end;end; { Process_ReadRichEditText }调试代码(环境是XP): Delphi(Pascal) codeprocedure TForm1.Button1Click(Sender: TObject);var vHandle: THandle;begin vHandle := FindWindow("WordPadClass", nil); if vHandle = 0 then Exit; vHandle := FindWindowEx(vHandle, 0, "RICHEDIT50W", nil); if vHandle = 0 then Exit; Memo1.Text := Process_ReadRichEditText(vHandle);end;

怎么使用delphi实现电脑硬件驱动安装??

1, 用copyFile复制文件,CopyFile("C:\\Autoexec.bat", "A:\\Backup\\Autoexec.bat", False);2. 可以用shellExecute加载已有的exe文件(应该也可以调用inf文件),比如运行记事本:uses ShellApi; // 加在开头units 中ShellExecute(Handle, "open", "c:\Windows\notepad.exe", nil, nil, SW_SHOWNORMAL) ;

VC++中将内存位图保存为文件时,怎样计算BITMAPFILEHEADER结...

从MSDN上贴过来的代码,注释挺详细了 The following example code defines a function that uses a BITMAPINFO structure and allocates memory for and initializes members within a BITMAPINFOHEADER structure. PBITMAPINFO CreateBitmapInfoStruct(HWND hwnd, HBITMAP hBmp) { BITMAP bmp; PBITMAPINFO pbmi; WORD cClrBits; // Retrieve the bitmap color format, width, and height. if (!GetObject(hBmp, sizeof(BITMAP), (LPSTR)&bmp)) errhandler("GetObject", hwnd); // Convert the color format to a count of bits. cClrBits = (WORD)(bmp.bmPlanes * bmp.bmBitsPixel); if (cClrBits == 1) cClrBits = 1; else if (cClrBits cClrBits = 4; else if (cClrBits cClrBits = 8; else if (cClrBits cClrBits = 16; else if (cClrBits cClrBits = 24; else cClrBits = 32; // Allocate memory for the BITMAPINFO structure. (This structure // contains a BITMAPINFOHEADER structure and an array of RGBQUAD // data structures.) if (cClrBits != 24) pbmi = (PBITMAPINFO) LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * (1 // There is no RGBQUAD array for the 24-bit-per-pixel format. else pbmi = (PBITMAPINFO) LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER)); // Initialize the fields in the BITMAPINFO structure. pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pbmi->bmiHeader.biWidth = bmp.bmWidth; pbmi->bmiHeader.biHeight = bmp.bmHeight; pbmi->bmiHeader.biPlanes = bmp.bmPlanes; pbmi->bmiHeader.biBitCount = bmp.bmBitsPixel; if (cClrBits pbmi->bmiHeader.biClrUsed = (1 // If the bitmap is not compressed, set the BI_RGB flag. pbmi->bmiHeader.biCompression = BI_RGB; // Compute the number of bytes in the array of color // indices and store the result in biSizeImage. // For Windows NT, the width must be DWORD aligned unless // the bitmap is RLE compressed. This example shows this. // For Windows 95/98/Me, the width must be WORD aligned unless the // bitmap is RLE compressed. pbmi->bmiHeader.biSizeImage = ((pbmi->bmiHeader.biWidth * cClrBits +31) & ~31) /8 * pbmi->bmiHeader.biHeight; // Set biClrImportant to 0, indicating that all of the // device colors are important. pbmi->bmiHeader.biClrImportant = 0; return pbmi; } The following example code defines a function that initializes the remaining structures, retrieves the array of palette indices, opens the file, copies the data, and closes the file. void CreateBMPFile(HWND hwnd, LPTSTR pszFile, PBITMAPINFO pbi, HBITMAP hBMP, HDC hDC) { HANDLE hf; // file handle BITMAPFILEHEADER hdr; // bitmap file-header PBITMAPINFOHEADER pbih; // bitmap info-header LPBYTE lpBits; // memory pointer DWORD dwTotal; // total count of bytes DWORD cb; // incremental count of bytes BYTE *hp; // byte pointer DWORD dwTmp; pbih = (PBITMAPINFOHEADER) pbi; lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, pbih->biSizeImage); if (!lpBits) errhandler("GlobalAlloc", hwnd); // Retrieve the color table (RGBQUAD array) and the bits // (array of palette indices) from the DIB. if (!GetDIBits(hDC, hBMP, 0, (WORD) pbih->biHeight, lpBits, pbi, DIB_RGB_COLORS)) { errhandler("GetDIBits", hwnd); } // Create the .BMP file. hf = CreateFile(pszFile, GENERIC_READ | GENERIC_WRITE, (DWORD) 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, (HANDLE) NULL); if (hf == INVALID_HANDLE_VALUE) errhandler("CreateFile", hwnd); hdr.bfType = 0x4d42; // 0x42 = "B" 0x4d = "M" // Compute the size of the entire file. hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) + pbih->biSize + pbih->biClrUsed * sizeof(RGBQUAD) + pbih->biSizeImage); hdr.bfReserved1 = 0; hdr.bfReserved2 = 0; // Compute the offset to the array of color indices. hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + pbih->biSize + pbih->biClrUsed * sizeof (RGBQUAD); // Copy the BITMAPFILEHEADER into the .BMP file. if (!WriteFile(hf, (LPVOID) &hdr, sizeof(BITMAPFILEHEADER), (LPDWORD) &dwTmp, NULL)) { errhandler("WriteFile", hwnd); } // Copy the BITMAPINFOHEADER and RGBQUAD array into the file. if (!WriteFile(hf, (LPVOID) pbih, sizeof(BITMAPINFOHEADER) + pbih->biClrUsed * sizeof (RGBQUAD), (LPDWORD) &dwTmp, ( NULL))) errhandler("WriteFile", hwnd); // Copy the array of color indices into the .BMP file. dwTotal = cb = pbih->biSizeImage; hp = lpBits; if (!WriteFile(hf, (LPSTR) hp, (int) cb, (LPDWORD) &dwTmp,NULL)) errhandler("WriteFile", hwnd); // Close the .BMP file. if (!CloseHandle(hf)) errhandler("CloseHandle", hwnd); // Free memory. GlobalFree((HGLOBAL)lpBits); }

DELPHI InternetGetCookie调用失败,有成功过的吗

unction InternetGetCookieEx(lpszUrl: DWORD; lpReserved: Pointer): BOOL; stdcall; var lpdwSize: DWORD; dwFlags;倒数第二个参数用$2000试试, lpszCookieName; external "wininet.dll" name "InternetGetCookieExA",lpszCookieData: PChar

VC判断文件是否存在

推荐实例例:if(::GetFileAttributes(m_filename)==-1){//文件不存在}else{//文件存在}1. 使用_access函数,函数原型为 int _access( const char *path, int mode );2. 使用CreateFile函数,函数原型为: HANDLE CreateFile( LPCTSTR lpFileName, // pointer to name of the file DWORD dwDesiredAccess, // access (read-write) mode DWORD dwShareMode, // share mode LPSECURITY_ATTRIBUTES lpSecurityAttributes, // pointer to security attributes DWORD dwCreationDisposition, // how to create DWORD dwFlagsAndAttributes, // file attributes HANDLE hTemplateFile // handle to file with attributes to // copy );3. 使用FindFirstFile函数,函数原型为: HANDLE FindFirstFile( LPCTSTR lpFileName, // pointer to name of file to search for LPWIN32_FIND_DATA lpFindFileData // pointer to returned information );4. 使用GetFileAttributes函数,函数原型如下: DWORD GetFileAttributes( LPCTSTR lpFileName // pointer to the name of a file or directory );5. 使用Shell Lightweight Utility APIs函数 PathFileExists()专门判断文件和目录时否存在的函数文件名可读性比较强还可以判断目录是否存在 Header: Declared in Shlwapi.h Import Library: Shlwapi.lib 以上的各种方法供参考,函数具体用法需参见MSDN

delphi 怎么获取工程版本号

function GetApplicationVersion:String; // Added 取得程序版本号 var FileName:String; InfoSize,Wnd:DWORD; VerBuf:Pointer; VerInfo:^VS_FIXEDFILEINFO; begin Result:="0.0.0.0"; FileName:=Application.ExeName; InfoSize:=GetFileVersionInfoSize(PChar(FileName),Wnd); if InfoSize0 then begin GetMem(VerBuf,InfoSize); try if GetFileVersionInfo(PChar(FileName),Wnd,InfoSize,VerBuf) then begin VerInfo:=nil; VerQueryValue(VerBuf,"\",Pointer(VerInfo),Wnd); if VerInfonil then Result:=Format("%d.%d.%d.%d",[VerInfo^.dwFileVersionMS shr 16, VerInfo^.dwFileVersionMS and $0000ffff, VerInfo^.dwFileVersionLS shr 16, VerInfo^.dwFileVersionLS and $0000ffff]); end; finally FreeMem(VerBuf,InfoSize); end; end; end;

CListCtrl::SortItems 内部数据怎么排序

列表控件(CListCtrl)的排序功能不像其它直接调用API就可以完成的功能一样.它比较复杂.今天将我的一点体会简单地谈一下. 列表控件的顶部有一排按钮,用户可以通过选择不同的列来对记录进行排序。

但是 CListCtrl并没有自动排序的功能,我们需要自己添加一个用于排序的回调函数来比较两个数据的大小,此外还需要响应排序按钮被点击的消息。

回调函数就好像是一个中断处理函数,操作系统在符合你设定的条件时自动调用。

·CListCtrl提供了用于排序的函数 函数原型为: BOOL CListCtrl::SortItems( PFNLVCOMPARE pfnCompare, DWORD dwData); 其中第一个参数为全局排序函数(它就是回调函数)的地址,第二个参数为用户数据,你可以根据你的需要传递一个数据或是指针。

该函数返回-1,代表第一项排应在第二项前面;返回1代表第一项排应在第二项后面;返回0代表两项相等。

·排序函数原形为: int CALLBACK ListCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); 其中第三个参数为调用者传递的数据(即调用SortItems时的第二个参数dwData)。

第一和第二个参数为用于比较的两项的ItemData,你可以通过 DWORD CListCtrl::GetItemData( int nItem )/ BOOL CListCtrl::SetItemData( int nItem, DWORD dwData )来对每一项的ItemData进行存取。

在添加项时选用特定的CListCtrl::InsertItem也可以设置该值。

由于你在排序时只能通过该值来确定项的位置所以你应该比较明确的确定该值的含义。

·我们什么时候需要排序(消息映射)呢? 实现这点可以在父窗口中对LVN_COLUMNCLICK消息进行处理来实现。

例子://排序回调函数实现 static int CALLBACK MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { // lParamSort contains a pointer to the list view control. // The lParam of an item is just its index. //以第一列为根据排序 CListCtrl* pListCtrl = (CListCtrl*) lParamSort; CString strItem1 = pListCtrl->GetItemText(lParam1, 0); CString strItem2 = pListCtrl->GetItemText(lParam2, 0); //比较两个数 LPCTSTR s1=(LPCTSTR)strItem1; LPCTSTR s2=(LPCTSTR)strItem2; int n1=atoi(s1); int n2=atoi(s2); if (n1>n2) return -1; else return 1; } void C***::OnColumnclickList(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; // TODO: Add your control notification handler code here //调用排序函数 m_ShowData.SortItems( MyCompareProc, (DWORD)&m_ShowData ); *pResult = 0; } 整个过程是这样的: 当你点击列表控件的表头时,此时它会向父窗口发送LVN_COLUMNCLICK消息,此时响应函数OnColumnclickList(),在该函数里面再调用列表控件的SortItems()成员函数,它会自动调用排序函数,完成排序功能.

大家还关注
    
阅读排行
推荐阅读