• 获取资源管理器路径


    XP

    #include <windows.h>
    #include <stdio.h>
    
    int main()
    {	
    	TCHAR str[100] = TEXT("Hello World");
    	HWND hwnd = NULL;
    
    	hwnd = FindWindowEx(NULL, NULL, TEXT("CabinetWClass"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("WorkerW"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("ReBarWindow32"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("ComboBoxEx32"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("ComboBox"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("Edit"), NULL);
    	
    	
    
    	
    	SendMessage(hwnd, WM_GETTEXT, 100, (LPARAM)str);
    	//SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)str);
    	//GetWindowText(hwnd, str, 100);
    	//MessageBox(NULL, str, TEXT("Cap"), 0);
    	wprintf(TEXT("%s
    "), str);
    	return 0;
    }
    

    关于GetWindowText为什么不可以用:

    http://www.cnblogs.com/MuyouSome/p/3333390.html

    Copies the text of the specified window's title bar (if it has one) into a buffer. If the specified window is a control, the text of the control is copied. However, GetWindowText cannot retrieve the text of a control in another application.


    WIN7

    #include <windows.h>
    #include <stdio.h>
    
    int main()
    {	
    	TCHAR str[100] = TEXT("Hello World");
    	HWND hwnd = NULL;
    
    	hwnd = FindWindowEx(NULL, NULL, TEXT("CabinetWClass"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("WorkerW"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("ReBarWindow32"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("Address Band Root"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("msctls_progress32"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("ComboBoxEx32"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("ComboBox"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("Edit"), NULL);
    
    	
    	SendMessage(hwnd, WM_GETTEXT, 100, (LPARAM)str);
    	//SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)str);
    	MessageBox(NULL, str, TEXT("Cap"), 0);
    	//wprintf(TEXT("%s
    "), str);
    	return 0;
    }
    
    

    上面这个还是比较鸡肋的:

    需要点击下地址栏才会出现ComboBoxEx32->ComboBox->Edit


    测试:

    通过点击向下箭头,刷新路径显示


    #include <windows.h>
    #include <stdio.h>
    #include <locale.h>
    
    int main()
    {	
    	TCHAR str[1024] = TEXT("Hello World");
    	HWND hwnd = NULL;
    	HWND hToolbat;
    	
    
    	hwnd = FindWindowEx(NULL, NULL, TEXT("CabinetWClass"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("WorkerW"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("ReBarWindow32"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("Address Band Root"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("msctls_progress32"), NULL);
    	hToolbat = FindWindowEx(hwnd, NULL, TEXT("ToolbarWindow32"), NULL);
    
    	
    	SendMessage(hToolbat, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(0, 0));
    	SendMessage(hToolbat, WM_LBUTTONUP, MK_LBUTTON, MAKELONG(0, 0));
    	SendMessage(hToolbat, WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(0, 0));
    	SendMessage(hToolbat, WM_LBUTTONUP, MK_LBUTTON, MAKELONG(0, 0));
    	
    	
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("ComboBoxEx32"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("ComboBox"), NULL);
    	hwnd = FindWindowEx(hwnd, NULL, TEXT("Edit"), NULL);
    	
    	if(hwnd == NULL)
    	{
    		wprintf(L"%s
    ", L"error");
    		return -1;
    	}
    	
    	SendMessage(hwnd, WM_GETTEXT, 1024, (LPARAM)str);
    	
    	MessageBox(NULL, str, TEXT("Caption"), 0);
    	return 0;
    }
    
    



    利用好wmic命令

    E:MyDocumentDesktop>wmic process /?
    
    PROCESS - Process management.
    
    HINT: BNF for Alias usage.
    (<alias> [WMIObject] | <alias> [<path where>] | [<alias>] <path where>) [<verb c
    lause>].
    
    USAGE:
    
    PROCESS ASSOC [<format specifier>]
    PROCESS CALL <method name> [<actual param list>]
    PROCESS CREATE <assign list>
    PROCESS DELETE
    PROCESS GET [<property list>] [<get switches>]
    PROCESS LIST [<list format>] [<list switches>]

    wmic process where caption="notepad.exe" get commandline /value
    wmic process where name="notepad.exe" get executablepath

    Keep it simple!
    作者:N3verL4nd
    知识共享,欢迎转载。
  • 相关阅读:
    TestNG并发测试包
    @Valid的坑
    spring boot 下 spring security 自定义登录配置与form-login属性详解
    在eclipse上搭建springBoot
    分页问题
    谷歌chrome://chrome-urls/
    chrome中清除dns缓存
    pg中的非varchar类型的模糊搜索
    spring中用xml配置构造注入的心得
    Flask-Limiter使用详细说明
  • 原文地址:https://www.cnblogs.com/lgh1992314/p/5834690.html
Copyright © 2020-2023  润新知