GET STATUS WIFI
Posted: Wed Sep 02, 2009 10:47 am
I foud a source to get status wifi , to open wifi and close wifi
it run on wm 6.1 and on my htc run ok
Perhaps some can translate it on fwppc
// GetWifiState.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <commctrl.h>
#include "..\Common\WirelessDevices.h"
int _tmain(int argc, _TCHAR* argv[])
{
// Load ossvcs.dll
BOOL res = InitDLL();
if (res)
{
DWORD dwWifi, dwPhone, dwBT;
GetWDevState(&dwWifi, &dwPhone, &dwBT);
// Free ossvcs.dll
DeinitDLL();
return dwWifi;
}
// Free ossvcs.dll
DeinitDLL();
return -1;
}
WirelessDevices.cpp
#include "stdafx.h"
#include "WirelessDevices.h"
_GetWirelessDevices pGetWirelessDevices = NULL;
_ChangeRadioState pChangeRadioState = NULL;
_FreeDeviceList pFreeDeviceList = NULL;
HINSTANCE g_DllWrlspwr;
BOOL InitDLL()
{
g_DllWrlspwr = LoadLibrary(TEXT("ossvcs.dll"));
if (g_DllWrlspwr == NULL)
return FALSE;
pGetWirelessDevices = (_GetWirelessDevices)GetProcAddress(g_DllWrlspwr,MAKEINTRESOURCE(GetWirelessDevice_ORDINAL));
if (pGetWirelessDevices == NULL)
return FALSE;
pChangeRadioState = (_ChangeRadioState)GetProcAddress(g_DllWrlspwr,MAKEINTRESOURCE(ChangeRadioState_ORDINAL));
if (pChangeRadioState == NULL)
return FALSE;
pFreeDeviceList = (_FreeDeviceList)GetProcAddress(g_DllWrlspwr,MAKEINTRESOURCE(FreeDeviceList_ORDINAL));
if (pFreeDeviceList == NULL)
return FALSE;
return TRUE;
}
BOOL DeinitDLL()
{
return FreeLibrary(g_DllWrlspwr);
}
// Set the status of the desired wireless device
DWORD SetWDevState(DWORD dwDevice, DWORD dwState)
{
RDD * pDevice = NULL;
RDD * pTD;
HRESULT hr;
DWORD retval = 0;
// InitDLL();
hr = pGetWirelessDevices(&pDevice, 0);
if(hr != S_OK) return -1;
if (pDevice)
{
pTD = pDevice;
// Loop through the linked list of devices
while (pTD)
{
if (pTD->DeviceType == dwDevice)
{
hr = pChangeRadioState(pTD, dwState, RADIODEVICES_PRE_SAVE);
retval = 0;
}
pTD = pTD->pNext;
}
// Free the list of devices retrieved with
// GetWirelessDevices()
pFreeDeviceList(pDevice);
}
if(hr == S_OK)return retval;
return -2;
}
WirelessDevices.c
#pragma once
#include <service.h>
#include <Wininet.h>
#include "wrlspwr.h"
#pragma comment(lib, "Wininet.lib")
// WLAN Switch
#define _WLAN_SWITCH_OFF 0
#define _WLAN_SWITCH_ON 1
// Phone Switch
#define _PHONE_SWITCH_OFF 0
#define _PHONE_SWITCH_ON 1
// BT Switch
#define _BT_SWITCH_OFF 0
#define _BT_SWITCH_ON 1
//
#define GetWirelessDevice_ORDINAL 276
#define ChangeRadioState_ORDINAL 273
#define FreeDeviceList_ORDINAL 280
// Imports from ossvcs.dll
typedef LRESULT (CALLBACK* _GetWirelessDevices)(RDD **pDevices, DWORD dwFlags);
typedef LRESULT (CALLBACK* _ChangeRadioState)(RDD* pDev, DWORD dwState, SAVEACTION sa);
typedef LRESULT (CALLBACK* _FreeDeviceList)(RDD* pRoot);
// Header of further functions
DWORD GetWDevState(DWORD* bWifi, DWORD* bPhone, DWORD* bBT);
DWORD SetWDevState(DWORD dwDevice, DWORD dwState);
BOOL DeinitDLL();
BOOL InitDLL();
wrlspwr.c
#pragma once
// Types of radio device
typedef enum _RADIODEVTYPE
{
RADIODEVICES_MANAGED = 1,
RADIODEVICES_PHONE,
RADIODEVICES_BLUETOOTH,
} RADIODEVTYPE;
// Whether to save before or after changing state
typedef enum _SAVEACTION
{
RADIODEVICES_DONT_SAVE = 0,
RADIODEVICES_PRE_SAVE,
RADIODEVICES_POST_SAVE,
} SAVEACTION;
// Details of radio devices
struct RDD
{
RDD() : pszDeviceName(NULL), pNext(NULL), pszDisplayName(NULL) {}
~RDD() { LocalFree(pszDeviceName); LocalFree(pszDisplayName); }
LPTSTR pszDeviceName; // Device name for registry setting.
LPTSTR pszDisplayName; // Name to show the world
DWORD dwState; // ON/off/[Discoverable for BT]
DWORD dwDesired; // desired state - used for setting registry etc.
RADIODEVTYPE DeviceType; // Managed, phone, BT etc.
RDD * pNext; // Next device in list
};
I can send U the other cpp files
it run on wm 6.1 and on my htc run ok
Perhaps some can translate it on fwppc
// GetWifiState.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <commctrl.h>
#include "..\Common\WirelessDevices.h"
int _tmain(int argc, _TCHAR* argv[])
{
// Load ossvcs.dll
BOOL res = InitDLL();
if (res)
{
DWORD dwWifi, dwPhone, dwBT;
GetWDevState(&dwWifi, &dwPhone, &dwBT);
// Free ossvcs.dll
DeinitDLL();
return dwWifi;
}
// Free ossvcs.dll
DeinitDLL();
return -1;
}
WirelessDevices.cpp
#include "stdafx.h"
#include "WirelessDevices.h"
_GetWirelessDevices pGetWirelessDevices = NULL;
_ChangeRadioState pChangeRadioState = NULL;
_FreeDeviceList pFreeDeviceList = NULL;
HINSTANCE g_DllWrlspwr;
BOOL InitDLL()
{
g_DllWrlspwr = LoadLibrary(TEXT("ossvcs.dll"));
if (g_DllWrlspwr == NULL)
return FALSE;
pGetWirelessDevices = (_GetWirelessDevices)GetProcAddress(g_DllWrlspwr,MAKEINTRESOURCE(GetWirelessDevice_ORDINAL));
if (pGetWirelessDevices == NULL)
return FALSE;
pChangeRadioState = (_ChangeRadioState)GetProcAddress(g_DllWrlspwr,MAKEINTRESOURCE(ChangeRadioState_ORDINAL));
if (pChangeRadioState == NULL)
return FALSE;
pFreeDeviceList = (_FreeDeviceList)GetProcAddress(g_DllWrlspwr,MAKEINTRESOURCE(FreeDeviceList_ORDINAL));
if (pFreeDeviceList == NULL)
return FALSE;
return TRUE;
}
BOOL DeinitDLL()
{
return FreeLibrary(g_DllWrlspwr);
}
// Set the status of the desired wireless device
DWORD SetWDevState(DWORD dwDevice, DWORD dwState)
{
RDD * pDevice = NULL;
RDD * pTD;
HRESULT hr;
DWORD retval = 0;
// InitDLL();
hr = pGetWirelessDevices(&pDevice, 0);
if(hr != S_OK) return -1;
if (pDevice)
{
pTD = pDevice;
// Loop through the linked list of devices
while (pTD)
{
if (pTD->DeviceType == dwDevice)
{
hr = pChangeRadioState(pTD, dwState, RADIODEVICES_PRE_SAVE);
retval = 0;
}
pTD = pTD->pNext;
}
// Free the list of devices retrieved with
// GetWirelessDevices()
pFreeDeviceList(pDevice);
}
if(hr == S_OK)return retval;
return -2;
}
WirelessDevices.c
#pragma once
#include <service.h>
#include <Wininet.h>
#include "wrlspwr.h"
#pragma comment(lib, "Wininet.lib")
// WLAN Switch
#define _WLAN_SWITCH_OFF 0
#define _WLAN_SWITCH_ON 1
// Phone Switch
#define _PHONE_SWITCH_OFF 0
#define _PHONE_SWITCH_ON 1
// BT Switch
#define _BT_SWITCH_OFF 0
#define _BT_SWITCH_ON 1
//
#define GetWirelessDevice_ORDINAL 276
#define ChangeRadioState_ORDINAL 273
#define FreeDeviceList_ORDINAL 280
// Imports from ossvcs.dll
typedef LRESULT (CALLBACK* _GetWirelessDevices)(RDD **pDevices, DWORD dwFlags);
typedef LRESULT (CALLBACK* _ChangeRadioState)(RDD* pDev, DWORD dwState, SAVEACTION sa);
typedef LRESULT (CALLBACK* _FreeDeviceList)(RDD* pRoot);
// Header of further functions
DWORD GetWDevState(DWORD* bWifi, DWORD* bPhone, DWORD* bBT);
DWORD SetWDevState(DWORD dwDevice, DWORD dwState);
BOOL DeinitDLL();
BOOL InitDLL();
wrlspwr.c
#pragma once
// Types of radio device
typedef enum _RADIODEVTYPE
{
RADIODEVICES_MANAGED = 1,
RADIODEVICES_PHONE,
RADIODEVICES_BLUETOOTH,
} RADIODEVTYPE;
// Whether to save before or after changing state
typedef enum _SAVEACTION
{
RADIODEVICES_DONT_SAVE = 0,
RADIODEVICES_PRE_SAVE,
RADIODEVICES_POST_SAVE,
} SAVEACTION;
// Details of radio devices
struct RDD
{
RDD() : pszDeviceName(NULL), pNext(NULL), pszDisplayName(NULL) {}
~RDD() { LocalFree(pszDeviceName); LocalFree(pszDisplayName); }
LPTSTR pszDeviceName; // Device name for registry setting.
LPTSTR pszDisplayName; // Name to show the world
DWORD dwState; // ON/off/[Discoverable for BT]
DWORD dwDesired; // desired state - used for setting registry etc.
RADIODEVTYPE DeviceType; // Managed, phone, BT etc.
RDD * pNext; // Next device in list
};
I can send U the other cpp files