Mô tả: Đoạn code lấy đường dẫn hiện hành (URL) của trình duyệt web
Ghi chú: Nếu có nhiều trình duyệt sử dụng nhiều thẻ (tab), thì nó lấy URL của thẻ đang được kích hoạt (active tab)
Mã:
/********************************************************** Description: Capture WebBrowser URL Author: gianghoplus [gianghoplus@gmail.com] Date: 23/08/2010 Copyright © 2010 www.congdongcviet.com ***********************************************************/ #include <windows.h>#include <ddeml.h>#include <stdio.h> BOOL GetBrowserURL(IN LPCSTR szName, OUT LPSTR szURL){ DWORD dwInst = 0, Long; DdeInitializeA (&dwInst, NULL, APPCLASS_STANDARD | APPCMD_CLIENTONLY, 0ul); HSZ hszService = DdeCreateStringHandleA (dwInst, szName, CP_WINANSI); HSZ hszTopic = DdeCreateStringHandleA (dwInst, "WWW_GetWindowInfo", CP_WINANSI); HSZ hszItem = DdeCreateStringHandleA (dwInst, "-1", CP_WINANSI); HCONV hConv = DdeConnect (dwInst, hszService, hszTopic, NULL); DdeFreeStringHandle (dwInst, hszService); DdeFreeStringHandle (dwInst, hszTopic); if (!hConv) return FALSE; HDDEDATA hRetVal = DdeClientTransaction (NULL, 0, hConv, hszItem, CF_TEXT, XTYP_REQUEST, 10000L, NULL); DdeFreeStringHandle(dwInst,hszItem); if (hRetVal > 0) sprintf(szURL,(LPSTR)DdeAccessData(hRetVal,(LPDWORD)&Long)); DdeUnaccessData(hRetVal); DdeFreeDataHandle(hRetVal); DdeDisconnect(hConv); return TRUE;} void main(){ CHAR szName[255] = "firefox"; // Ex: "iexplore", "opera", ... while (true) { CHAR szURL[255] = {0}; BOOL bRet = GetBrowserURL(szName, szURL); if (bRet) printf("%s
", szURL); else printf("Error: Cannot connect to %s.
", szName); Sleep(1000); }}
Pallet nhựa Lâm Đồng giải pháp hoàn hảo cho nhà kho Pallet nhựa Lâm Đồng là một giải pháp đa năng và hiệu quả trong việc vận chuyển và lưu trữ hàng hóa. Trong đó, pallet nhựa Lâm Đồng không chỉ đáp...
Pallet nhựa Lâm Đồng giải pháp...