Gunta писал(а):
Список доступных Wi-Fi сетей и их уровни сигналов (для ноутбуков с wifi картой)или так
Add(MainForm,2953706,70,119)
{
link(onCreate,726974:doDeferredEvent,[])
}
Add(InlineCode,14066311,175,133)
{
WorkPoints=#17:doWlanNetworkList|
EventPoints=#11:omInterface|17:onWlanNetworkList|15:onStartScanning|13:onEndScanning|
Code=#15:unit HiAsmUnit;|0:|9:interface|0:|46:uses kol,Windows,Share,Debug,Messages,ActiveX;|0:|5:const|43: WLAN_NOTIFICATION_SOURCE_ACM = $00000008;|42: wlan_notification_acm_scan_complete = 7;|49: wlan_notification_acm_power_setting_change = 6;|0:|4:type|18: PDWORD = ^DWORD;|2: |25: TWlanInterfaceState = (|58: wlan_is_not_ready, wlan_is_connected, wlan_is_ad_hoc, |70: wlan_is_disconnecting, wlan_is_disconnected, wlan_is_associating, |47: wlan_is_discovering, wlan_is_authenticating|4: );|0:|29: TWlanInterfaceInfo = record|25: InterfaceGuid: TGUID;|55: strInterfaceDescription: array[0..255] of WideChar;|33: isState: TWlanInterfaceState;|6: end;|0:|51: PWlanInterfaceInfoList = ^TWlanInterfaceInfoList;|33: TWlanInterfaceInfoList = record|27: dwNumberOfItems: DWORD;|19: dwIndex: DWORD;|53: InterfaceInfo: array[0..0] of TWlanInterfaceInfo;|6: end;|0:|21: TDot11Ssid = record|23: uSSIDLength: ULONG;|37: ucSSID: array[0..31] of AnsiChar;|6: end;|0:|32: TWlanAvailableNetwork = record|46: strProfileName: array[0..255] of WideChar;|26: dot11Ssid: TDot11Ssid;|26: dot11BssType: Integer;|27: uNumberOfBssids: ULONG;|30: bNetworkConnectable: BOOL;|36: wlanNotConnectableReason: DWORD;|29: uNumberOfPhyTypes: ULONG;|42: dot11PhyTypes: array[0..7] of Integer;|24: bMorePhyTypes: BOOL;|29: wlanSignalQuality: ULONG;|27: bSecurityEnabled: BOOL;|39: dot11DefaultAuthAlgorithm: Integer;|41: dot11DefaultCipherAlgorithm: Integer;|19: dwFlags: DWORD;|22: dwReserved: DWORD;|6: end;|0:|57: PWlanAvailableNetworkList = ^TWlanAvailableNetworkList;|36: TWlanAvailableNetworkList = record|27: dwNumberOfItems: DWORD;|19: dwIndex: DWORD;|50: Network: array[0..0] of TWlanAvailableNetwork;|6: end;|0:|49: PWlanNotificationData = ^TWlanNotificationData;|32: TWlanNotificationData = record|30: NotificationSource: DWORD;|28: NotificationCode: DWORD;|25: InterfaceGuid: TGUID;|22: dwDataSize: DWORD;|19: pData: Pointer;|6: end;|0:|96: TWlanNotificationCallback = procedure(data: PWlanNotificationData; context: Pointer); stdcall;|0:|27: TWlanScanContext = record|42: InterfaceList: PWlanInterfaceInfoList;|23: Semaphore: THandle;|6: end;|39: PWlanScanContext = ^TWlanScanContext;|0:|4:type|107: TWlanOpenHandle = function(dwVer: DWORD; pRes: Pointer; var nVer: DWORD; var h: THandle): DWORD; stdcall;|73: TWlanCloseHandle = function(h: THandle; pRes: Pointer): DWORD; stdcall;|109: TWlanEnumInterfaces = function(h: THandle; pRes: Pointer; var ppL: PWlanInterfaceInfoList): DWORD; stdcall;|51: TWlanFreeMemory = procedure(p: Pointer); stdcall;|172: TWlanRegisterNotification = function(h: THandle; dwSrc: DWORD; bIgn: BOOL; cb: TWlanNotificationCallback; pCtx: Pointer; pRes: Pointer; var pPrev: DWORD): DWORD; stdcall;|116: TWlanScan = function(h: THandle; const pGuid: TGUID; pSsid: Pointer; pIe: Pointer; pRes: Pointer): DWORD; stdcall;|157: TWlanGetAvailableNetworkList = function(h: THandle; const pGuid: TGUID; dwFlags: DWORD; pRes: Pointer; var ppL: PWlanAvailableNetworkList): DWORD; stdcall;|0:|0:|0:|4:type|28: THiAsmClass = class(TDebug)|10: private|0:|9: public|0:|72:onWlanNetworkList,omInterface,onStartScanning,onEndScanning : THI_Event;|0:|58:Procedure doWlanNetworkList (var _Data:TData; Index:word);|0:|5: end;|0:|14:implementation|0:|63:function CompareMem(P1, P2: Pointer; Length: Integer): Boolean;|3:var|13: i: Integer;|16: B1, B2: PByte;|5:begin|18: Result := False;|17: if P1 = P2 then|7: begin|19: Result := True;|9: Exit;|6: end;|40: if (P1 = nil) or (P2 = nil) then Exit;|2: |11: B1 := P1;|11: B2 := P2;|25: for i := 1 to Length do|7: begin|28: if B1^ <> B2^ then Exit;|12: Inc(B1);|12: Inc(B2);|6: end;|17: Result := True;|4:end;|0:|0:|91:procedure WlanNotificationCallback(data: PWlanNotificationData; context: Pointer); stdcall;|3:var|24: ctx: PWlanScanContext;|13: i: Integer;|16: prev: Longint;|5:begin|74: if (data^.NotificationSource and WLAN_NOTIFICATION_SOURCE_ACM) <> 0 then|7: begin|73: if (data^.NotificationCode = wlan_notification_acm_scan_complete) or |81: (data^.NotificationCode = wlan_notification_acm_power_setting_change) then|9: begin|39: ctx := PWlanScanContext(context);|62: for i := 0 to ctx^.InterfaceList^.dwNumberOfItems - 1 do|116: if CompareMem(@ctx^.InterfaceList^.InterfaceInfo[i].InterfaceGuid, @data^.InterfaceGuid, SizeOf(TGUID)) then|155: PDWORD(@ctx^.InterfaceList^.InterfaceInfo[i].isState)^ := DWORD(ctx^.InterfaceList^.InterfaceInfo[i].isState) or (data^.NotificationCode shl 16);|49: ReleaseSemaphore(ctx^.Semaphore, 1, @prev);|8: end;|6: end;|4:end;|0:|0:|71:Procedure THiAsmClass.doWlanNetworkList (var _Data:TData; Index:word);|0:|3:var|20: hWlanLib: THandle;|88: WlanOpen: TWlanOpenHandle; WlanClose: TWlanCloseHandle; WlanEnum: TWlanEnumInterfaces;|87: WlanFree: TWlanFreeMemory; WlanReg: TWlanRegisterNotification; WlanDoScan: TWlanScan;|44: WlanGetList: TWlanGetAvailableNetworkList;|53: hClient: THandle; dwVer, dwPrev, res, nWait: DWORD;|69: pList: PWlanInterfaceInfoList; pNetList: PWlanAvailableNetworkList;|53: ctx: TWlanScanContext; i, j: Integer; ssid: string;|17: outStr: string;|2: |5:begin|41: hWlanLib := LoadLibrary('wlanapi.dll');|28: if hWlanLib = 0 then Exit;|0:|58: @WlanOpen := GetProcAddress(hWlanLib, 'WlanOpenHandle');|60: @WlanClose := GetProcAddress(hWlanLib, 'WlanCloseHandle');|62: @WlanEnum := GetProcAddress(hWlanLib, 'WlanEnumInterfaces');|58: @WlanFree := GetProcAddress(hWlanLib, 'WlanFreeMemory');|67: @WlanReg := GetProcAddress(hWlanLib, 'WlanRegisterNotification');|54: @WlanDoScan := GetProcAddress(hWlanLib, 'WlanScan');|74: @WlanGetList := GetProcAddress(hWlanLib, 'WlanGetAvailableNetworkList');|0:|71: if Assigned(WlanOpen) and (WlanOpen(1, nil, dwVer, hClient) = 0) then|7: begin|45: if WlanEnum(hClient, nil, pList) = 0 then|9: begin|33: ctx.InterfaceList := pList;|76: ctx.Semaphore := CreateSemaphore(nil, 0, pList^.dwNumberOfItems, nil);|17: nWait := 0;|106: WlanReg(hClient, WLAN_NOTIFICATION_SOURCE_ACM, FALSE, @WlanNotificationCallback, @ctx, nil, dwPrev);|0:|39: _hi_OnEvent(onStartScanning,''); |49: for i := 0 to pList^.dwNumberOfItems - 1 do|11: begin|89: res := WlanDoScan(hClient, pList^.InterfaceInfo[i].InterfaceGuid, nil, nil, nil);|102: PDWORD(@pList^.InterfaceInfo[i].isState)^ := DWORD(pList^.InterfaceInfo[i].isState) and $FFFF;|34: if res = 0 then Inc(nWait)|113: else PDWORD(@pList^.InterfaceInfo[i].isState)^ := DWORD(pList^.InterfaceInfo[i].isState) or (res shl 16);|10: end;|0:|89: while nWait > 0 do begin WaitForSingleObject(ctx.Semaphore, 5000); Dec(nWait); end;|0:|49: for i := 0 to pList^.dwNumberOfItems - 1 do|11: begin|97: if WlanGetList(hClient, pList^.InterfaceInfo[i].InterfaceGuid, 2, nil, pNetList) = 0 then|13: begin|110: _hi_OnEvent(omInterface,WideCharLenToString(@pList^.InterfaceInfo[i].strInterfaceDescription, 256));|56: for j := 0 to pNetList^.dwNumberOfItems - 1 do|15: begin|111: SetString(ssid, pNetList^.Network[j].dot11Ssid.ucSSID, pNetList^.Network[j].dot11Ssid.uSSIDLength);|110: _hi_OnEvent(onWlanNetworkList, ssid + ';' + Int2Str(pNetList^.Network[j].wlanSignalQuality)+ '%');|14: end;|29: WlanFree(pNetList);|12: end;|10: end;|33: CloseHandle(ctx.Semaphore);|22: WlanFree(pList);|8: end;|28: WlanClose(hClient, nil);|6: end;|24: FreeLibrary(hWlanLib);|0:|33: _hi_OnEvent(onEndScanning,''); |4:end;|0:|4:end.|
link(omInterface,2953706:doCaption,[(214,139)(214,111)(60,111)(60,125)])
link(onWlanNetworkList,5563891:doAdd,[])
}
Add(StringTable,5563891,245,140)
{
Left=265
Top=185
Align=5
Columns=#8:ssid=300|11:signal=100 |0:|
}
Add(DeferredEvent,726974,126,133)
{
link(onDeferredEvent,14066311:doWlanNetworkList,[])
}



Поиск
Друзья
Администрация