1:FindWindow
2:GetWindowThreadProcessId
3:OpenProcess
4:CloseHandle
5:WriteProcessMemory
6:ReadProcessMemory
那位高手可以指教下  这些api在vc中怎么用,最好举例说说
本人不胜感激

解决方案 »

  1.   

    HWND FindWindow(
      LPCTSTR lpClassName,  // pointer to class name
      LPCTSTR lpWindowName  // pointer to window name
    );DWORD GetWindowThreadProcessId(
      HWND hWnd,             // handle to window
      LPDWORD lpdwProcessId  // address of variable for process identifier
    );HANDLE OpenProcess(
      DWORD dwDesiredAccess,  // access flag
      BOOL bInheritHandle,    // handle inheritance flag
      DWORD dwProcessId       // process identifier
    );BOOL CloseHandle(
      HANDLE hObject   // handle to object to close
    );BOOL WriteProcessMemory(
      HANDLE hProcess,  // handle to process whose memory is written to
      LPVOID lpBaseAddress,
                        // address to start writing to
      LPVOID lpBuffer,  // pointer to buffer to write data to
      DWORD nSize,      // number of bytes to write
      LPDWORD lpNumberOfBytesWritten 
                        // actual number of bytes written
    );BOOL ReadProcessMemory(
      HANDLE hProcess,  // handle to the process whose memory is read
      LPCVOID lpBaseAddress,
                        // address to start reading
      LPVOID lpBuffer,  // address of buffer to place read data
      DWORD nSize,      // number of bytes to read
      LPDWORD lpNumberOfBytesRead 
                        // address of number of bytes read
    );
      

  2.   

    在vb下我可以成功使用  
    但是vc下我搞不定   高手指点我
      

  3.   

    LPCVOID,LPDWORD,LPCTSTR
    这几个类型的变量到底是什么东西啊   可以说说吗?
    凡是关于这几个类型的都说我搞得不对
      

  4.   

    FindWindow查找指定类名或标题的窗口,MSDN中的例子如下:/* SPI_GETWHEELSCROLLLINES
       is defined in winuser.h beginning with Windows NT 4.0. The
       SystemParametersInfo function has been updated for the scrolllines
       functionality.
    */#ifndef SPI_GETWHEELSCROLLLINES
    #define SPI_GETWHEELSCROLLLINES   104
    #endif#include "zmouse.h"/*********************************************************
    * FUNCTION: GetNumScrollLines
    * Purpose : An OS independent method to retrieve the 
    *           number of wheel scroll lines
    * Params  : none
    * Returns : UINT:  Number of scroll lines where WHEEL_PAGESCROLL 
    *           indicates to scroll a page at a time.
    *********************************************************/
    UINT GetNumScrollLines(void)
    {
       HWND hdlMsWheel;
       UINT ucNumLines=3;  // 3 is the default
       OSVERSIONINFO osversion;
       UINT uiMsh_MsgScrollLines;
          memset(&osversion, 0, sizeof(OSVERSIONINFO));
       osversion.dwOSVersionInfoSize =sizeof(OSVERSIONINFO);
       GetVersionEx(&osversion);   // In Windows 9x & Windows NT 3.51, query MSWheel for the
       // number of scroll lines. In Windows NT 4.0 and later,
       // use SystemParametersInfo.    if ((osversion.dwPlatformId ==
                            VER_PLATFORM_WIN32_WINDOWS) ||
           ( (osversion.dwPlatformId ==
                          VER_PLATFORM_WIN32_NT) && 
             (osversion.dwMajorVersion < 4) )   )
       {
            hdlMsWheel = FindWindow(MSH_WHEELMODULE_CLASS, 
                                    MSH_WHEELMODULE_TITLE);
            if (hdlMsWheel)
            {
               uiMsh_MsgScrollLines = RegisterWindowMessage
                                         (MSH_SCROLL_LINES);
               if (uiMsh_MsgScrollLines)
                    ucNumLines = (int)SendMessage(hdlMsWheel,
                                        uiMsh_MsgScrollLines, 
                                                           0, 
                                                           0);
            }
       }
       else if ( (osversion.dwPlatformId ==
                             VER_PLATFORM_WIN32_NT) &&
                 (osversion.dwMajorVersion >= 4) )
       {
          SystemParametersInfo(SPI_GETWHEELSCROLLLINES,
                                              0,
                                        &ucNumLines, 0);
       }
       return(ucNumLines);
    }
      

  5.   

    哇  我的msdn中咋就没例子啊
      

  6.   

    GetWindowThreadProcessId得到指定窗口句柄的进程、线程ID,例子如下:
    DWORD pID; /* 进程ID */
    DWORD tID; /* 线程ID */
    HWND hFore;hFore = GetForegroundWindow ();
    tID = GetWindowThreadProcessId (hFore, &pID);
      

  7.   

    hdlMsWheel = FindWindow(MSH_WHEELMODULE_CLASS, MSH_WHEELMODULE_TITLE);
    这个函数中的两个宏是怎么定义的啊
      

  8.   

    The FindWindow function retrieves a handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows. This function does not perform a case-sensitive search. To search child windows, beginning with a specified child window, use the FindWindowEx function. HWND FindWindow(
      LPCTSTR lpClassName,  // class name
      LPCTSTR lpWindowName  // window name
    );
    Parameters
    lpClassName 
    [in] Pointer to a null-terminated string that specifies the class name or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom must be in the low-order word of lpClassName; the high-order word must be zero. 
    If lpClassName is a string, it specifies the window class name. The class name can be any name registered with RegisterClass or RegisterClassEx, or any of the predefined control-class names. lpWindowName 
    [in] Pointer to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match. 
    Return Values
    If the function succeeds, the return value is a handle to the window that has the specified class name and window name.If the function fails, the return value is NULL. To get extended error information, call GetLastError. Res
    If the lpWindowName parameter is not NULL, FindWindow calls the GetWindowText function to retrieve the window name for comparison. For a description of a potential problem that can arise, see the Res for GetWindowText. 通过class名或窗口名来查找窗口,不包括子窗口,
      
      

  9.   

    lpszClassName
    FindWindow(MSH_WHEELMODULE_CLASS, MSH_WHEELMODULE_TITLE);
    Points to a null-terminated string that specifies the window’s class name (a WNDCLASS structure). If lpClassName is NULL, all class names match.lpszWindowNamePoints to a null-terminated string that specifies the window name (the window’s title). If lpWindowName is NULL, all window names match.
      

  10.   

    FindWindow(NULL,"mu")
    我在vb中这样写可以通过但是在vc中就通不过
      

  11.   

    函数功能:该函数获得一个顶层窗口的句柄,该窗口的类名和窗口名与给定的字符串相匹配。这个函数不查找子窗口。在查找时不区分大小写。    函数型:HWND FindWindow(LPCTSTR IpClassName,LPCTSTR IpWindowName);    参数:    IpClassName :指向一个指定了类名的空结束字符串,或一个标识类名字符串的成员的指针。如果该参数为一个成员,则它必须为前次调用theGlobafAddAtom函数产生的全局成员。该成员为16位,必须位于IpClassName的低 16位,高位必须为 0。    IpWindowName:指向一个指定了窗口名(窗口标题)的空结束字符串。如果该参数为空,则为所有窗口全匹配。    返回值:如果函数成功,返回值为具有指定类名和窗口名的窗口句柄;如果函数失败,返回值为NULL。    若想获得更多错误信息,请调用GetLastError函数。    备注:Windows CE:若类名是一个成员,它必须是从 RegisterClass返回的成员。    速查:Windows NT:3.1以上版本;Windows:95以上版本;Windows CE:1.0以上版本;头文件:Winuser.h;库文件:user32.lib; Unicode:在 Windows NT上实现为 Unicode和 ANSI两种版本。
    函数功能:该函数返回创建指定窗口线程的标识和创建窗口的进程的标识符,后一项是可选的。    函数原型;DWORD GetWindowThreadProcessld(HWND hwnd,LPDWORD lpdwProcessld);    参数:    hWnd:窗口句柄。    lpdwProcessld:接收进程标识的32位值的地址。如果这个参数不为NULL,GetWindwThreadProcessld将进程标识拷贝到这个32位值中,否则不拷贝。    返回值:返回值为创建窗口的线程标识。    速查:Windows NT:3.1以上版本;Windows:95以上版本;Windows CE:1.0以上版本;头文件:winuser.h;库文件;user32.lib。
      

  12.   

    谢谢大家的指导  程序调试成功了
    但是运行时老说什么内存不能访问  请问这是什么原因啊
    好像是这个函数有点问题OpenProcess
    我是这样写的HANDLE phand=::OpenProcess(PROCESS_ALL_ACCESS,TRUE,*pid);
    指点啊