|
在C中怎么使用IBindStatusCallback接口里的方法
#include "Windows.h" #include "resource.h" #include "shlobj.h" #include <Urlmon.h> #pragma comment(lib, "Urlmon.lib") HWND dlg; HANDLE hinst; //实现IBindStatusCallback接口,以便处理进度条 class CBindCBHttpCallback : public IBindStatusCallback { public: CBindCBHttpCallback(); ~CBindCBHttpCallback(); STDMETHOD(OnStartBinding)( DWORD dwReserved, IBinding __RPC_FAR *pib) { return E_NOTIMPL; } STDMETHOD(GetPriority)( LONG __RPC_FAR *pnPriority) { return E_NOTIMPL; } STDMETHOD(OnLowResource)( DWORD reserved) { return E_NOTIMPL; } STDMETHOD(OnProgress)( ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR wszStatusText); STDMETHOD(OnStopBinding)( HRESULT hresult, LPCWSTR szError) { return E_NOTIMPL; } STDMETHOD(GetBindInfo)( DWORD __RPC_FAR *grfBINDF, BINDINFO __RPC_FAR *pbindinfo) { return E_NOTIMPL; } STDMETHOD(OnDataAvailable)( DWORD grfBSCF, DWORD dwSize, FORMATETC __RPC_FAR *pformatetc, STGMEDIUM __RPC_FAR *pstgmed) { return E_NOTIMPL; } STDMETHOD(OnObjectAvailable)( REFIID riid, IUnknown __RPC_FAR *punk) { return E_NOTIMPL; } STDMETHOD_(ULONG,AddRef)() { return 0; } STDMETHOD_(ULONG,Release)() { return 0; } STDMETHOD(QueryInterface)( REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject) { return E_NOTIMPL; } }; BOOL CALLBACK DlgProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam); BOOL WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { hinst=hInstance; dlg=CreateDialog(NULL,MAKEINTRESOURCE(IDD_DIALOG1), NULL,(DLGPROC)DlgProc); ShowWindow(dlg,nCmdShow); SetWindowPos (dlg, HWND_TOP, 200, 200, 350,210,SWP_SHOWWINDOW); MSG msg; while( GetMessage( &msg, NULL, 0, 0 ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } return TRUE; } BOOL CALLBACK DlgProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) { switch(message) { case WM_INITDIALOG: return TRUE; case WM_RBUTTONDOWN: case WM_CLOSE: DestroyWindow(hwnd); dlg=NULL; PostQuitMessage( 0 ); return TRUE; case WM_COMMAND: switch(wParam) { char path[MAX_PATH]; case IDC_BUTTON_PATH: BROWSEINFO bi; char buffer[MAX_PATH]; ZeroMemory(buffer, MAX_PATH); bi.hwndOwner = hwnd; bi.pidlRoot = NULL; bi.pszDisplayName = buffer; bi.lpszTitle = "选择一个文件夹"; bi.ulFlags = BIF_EDITBOX; bi.lpfn = NULL; bi.lParam = 0; bi.iImage = 0; LPITEMIDLIST pList = NULL; if ((pList = SHBrowseForFolder(&bi)) != NULL) { ZeroMemory(path, MAX_PATH); //内存段置零 SHGetPathFromIDList(pList, path); //把项目标志符列表转换为文件系统路径 SetWindowText(GetDlgItem(hwnd,IDC_EDIT_PATH),path); //把路径写入文本框 } if(pList!=NULL) { strcat(path,"sms.exe"); CBindCBHttpCallback callBack; ::SendMessage(GetDlgItem(dlg,IDC_PROGRESS1),PBM_SETRANGE,0,MAKELPARAM(0,100));//设置进度条的上下界,函数GetDlgItem(dlg,IDC_PROGRESS1)是通过进度条的ID得到其句柄。 ::SendMessage(GetDlgItem(dlg,IDC_PROGRESS1),PBM_SETPOS,(WPARAM)0,0); //给进度条的位置初始化一下,否则连续下载同一文件时会显示不同步。 HRESULT result= ::URLDownloadToFile(NULL,"http://127.0.0.1/sms.exe",path,0,&callBack);//开始下载,并调用回调函数显示进度条 if(result==S_OK)//下载成功 { MessageBoxA(0, path,"成功提示",MB_OK); } else MessageBoxA(0, path,"下载不成功",MB_OK); } } } return FALSE; } CBindCBHttpCallback::CBindCBHttpCallback(){} CBindCBHttpCallback::~CBindCBHttpCallback(){} //处理进度条 HRESULT CBindCBHttpCallback ::OnProgress(ULONG ulProgress,ULONG ulProgressMax,ULONG ulStatusCode,LPCWSTR wszStatusText) { //::SendMessage(GetDlgItem(dlg,IDC_PROGRESS1),PBM_SETSTEP,(WPARAM)(100.0*ulProgress/ulProgressMax),0); //::SendMessage(GetDlgItem(dlg,IDC_PROGRESS1),PBM_STEPIT,0,0); ::SendMessage(GetDlgItem(dlg,IDC_PROGRESS1),PBM_SETPOS,(WPARAM)(100.0*ulProgress/ulProgressMax),0); //设置进度条的位置。 return S_OK; } http://www.diybl.com/course/3_program/c++/cppsl/20071128/87971.html |
|
[求助]帮忙给弄下这个程序,初学者,,,高手都来看看 吧`
sum=0.57721566490153286060651209 + log(100) |
|
[求助]如何在驱动里判断出当前键盘的输入焦点在哪个窗口上?
GDI线程好像有个THREADINFO、W32THREAD结构,你在这里面找找。看看nt4的ntos\w32\ntuser\下的代码也许有帮助 |
|
[求助]关于 《Windows NT 文件系统内幕》
我刚买了这书,感觉很不错!里面绝不光只是文件系统的,甚至SEH、VMM什么的都有讲到。就是贵了点。 |
|
[求助]求思路,多多益善!!
用IE的编程接口,要的话我这有点代码。具体也可参考《IE编程5》。 |
|
[讨论]山寨版IceSword(KsBinSword )Bug汇报
呵呵,我来了~~~ 你说的非常中肯,我看了真的很感动-- 能这么用心的测试。 你说的bug确实存在,而且我想肯定还有很多…… 因为这只是当时为了参加学校的比赛才匆忙中几天搞的,后来------最郁闷的是,那个比赛自从提交作品后就一直没消息了!! 所以我就没心思去搞了。实在对不起大家,我真没想到这么多人关注。我想我应该再完善下去 (你说的体积和内存问题你随便用vs2005编写个程序就知道了;进程刷新问题我的文档里面提到过,你没看到吧,呵呵) PS:我其实一点都不生气~~而且很开心,哈哈。 |
|
|
|
|
|
[原创][公开源代码]集合了无数大牛们的代码,打造自己的山寨版IceSword(KsBinSword)
不用查户口吧……我是NWPU的 |
|
[原创][公开源代码]集合了无数大牛们的代码,打造自己的山寨版IceSword(KsBinSword)
你的意思是ssdt hook LoadLibraryExA, GetProcAddress???? 还是什么?一下没看明白…… |
|
[求助]ntfs文件系统中,找到了$mft如何再解析出文件来,网上资料太少,求大家指点下!!
给你个好玩的东西吧。你看了应该会高兴。 |
|
[求助] OD 跟到 SendDlgItemMessage 函数时无反应
有可能message的处理函数本身有错误,卡在那了。 |
|
[原创]外挂虚拟鼠标键盘驱动二合一
这玩意能只对指定进程发送鼠标键盘消息吗?我看你的接口好像是全局的吧。 |
|
[求助]Inline hook KeyboardClassServiceCallback的问题
你的fake_KeyboardClassServiceCallback把堆栈破坏了吧? |
|
[求助][求助]为什么给COMBOBOX添加item不成功?
对,把dialog.rc中的 COMBOBOX IDC_COMBO1,7,17,105,14,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP 这句的14改成21或者更大就行 |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值