| |

VB.NET - Ein- und UmsteigerWLAN am PDA aktivieren | |  | Autor: tomtom2010 | Datum: 01.06.07 01:22 |
| Hi!
Bin auf der suche nach einer möglichkeit, die wlan antenne meines pda mit meinem programm einzuschalten.. ich hab das ganze schon einmal gepostet, jetzt aber was neues:
ich hab von einem typen von einer firma, die das in einem tool von denen gemacht hat den c++ code für das problem bekommen.. ich kann leider kein c/c++ und würde dringend hilfe brauchen: kann das wer übersetzen??
hier sein code mit erklärung:
Activating the WiFi adapter is really easy. I figured C/C++ code below. You
can activate using SetDevicePower API with PwrDeviceUnspecified to turn on
the WiFi.
----------------------------------------------------------
LONG SetAdapterPowerState(LPTSTR pszWLANAdapterName, BOOL bPowerOn)
{
LONG lRet = -1;
CEDEVICE_POWER_STATE Dx = PwrDeviceUnspecified;
TCHAR szName[MAX_PATH];
int nChars;
memset(szName, 0, MAX_PATH*sizeof(TCHAR));
// PMCLASS_NDIS_MINIPORT is defined in pm.h
nChars = _sntprintf(szName, MAX_PATH-1, _T("%s\\%s"),
PMCLASS_NDIS_MINIPORT, pszWLANAdapterName);
if(nChars != (-1))
lRet = SetDevicePower(szName, POWER_NAME, (bPowerOn?
PwrDeviceUnspecified : D4));
return lRet;
}
----------------------------------------------------------
In case of above way, at first, you have to find a WiFi adapter instance
name. It can be found using the RequestDeviceNotification and ReadMsgQueue
APIs like below.
----------------------------------------------------------
// Declear PMCLASS_NDIS_MINIPORT as a GUID.
static const GUID DEVCLASS_POWER_NDIS_MINIPORT_GUID = { 0x98C5250D,
0xC29A, 0x4985, {0xAE, 0x5F, 0xAF, 0xE5, 0x36, 0x7E, 0x50, 0x06} };
BOOL FindWiFiAdapter(LPTSTR pszWLANAdapterName, DWORD cchMaxNameLen)
{
BOOL bFound = FALSE;
BYTE pPNPBuf[MAX_DEVCLASS_NAMELEN];
MSGQUEUEOPTIONS msgopts = {0};
DEVDETAIL *pd = (DEVDETAIL*)pPNPBuf;
GUID guid = DEVCLASS_POWER_NDIS_MINIPORT_GUID;
HANDLE hMsgQueue;
HANDLE hDevNotify;
DWORD dwSize, dwFlags;
// Check parameters
if (!cchMaxNameLen || !pszWLANAdapterName)
{
// Error....
}
// Create a message queue
msgopts.dwSize = sizeof(MSGQUEUEOPTIONS);
msgopts.dwFlags = 0;
msgopts.dwMaxMessages = 0;
msgopts.cbMaxMessage = sizeof(pPNPBuf);
msgopts.bReadAccess = TRUE;
hMsgQueue = CreateMsgQueue(NULL, &msgopts);
if (hMsgQueue)
{
// Start DeviceNotification
hDevNotify = RequestDeviceNotifications(&guid, hMsgQueue, TRUE);
if (hDevNotify)
{
while (ReadMsgQueue(hMsgQueue, pd, sizeof(pPNPBuf), &dwSize, 0,
&dwFlags))
{
if (0 == memcmp(&pd->guidDevClass,
&DEVCLASS_POWER_NDIS_MINIPORT_GUID, sizeof(GUID)))
{
_tcsncpy(pszWLANAdapterName, pd->szName, cchMaxNameLen);
bFound = TRUE;
break;
}
}
StopDeviceNotifications(hDevNotify);
}
else
{
// Error....
}
CloseMsgQueue(hMsgQueue);
}
return bFound;
}
---------------------------------------------------------- |  |
 WLAN am PDA aktivieren | 1.472 | tomtom2010 | 01.06.07 01:22 |
 | Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
  |
|
Neu! sevPopUp 2.0 
Dynamische Kontextmenüs!
Erstellen Sie mit nur wenigen Zeilen Code Kontextmenüs dynamisch zur Laufzeit. Vordefinierte Styles (XP, Office, OfficeXP, Vista oder Windows 8) erleichtern die Anpassung an die eigenen Anwendung... Weitere InfosTipp des Monats Oktober 2025 Matthias KozlowskiUmlaute konvertierenErsetzt die Umlaute in einer Zeichenkette durch die entsprechenden Doppelbuchstaben (aus ä wird ae, usw.) TOP Entwickler-Paket 
TOP-Preis!!
Mit der Developer CD erhalten Sie insgesamt 24 Entwickler- komponenten und Windows-DLLs. Die Einzelkomponenten haben einen Gesamtwert von 1866.50 EUR...
Jetzt nur 979,00 EURWeitere Infos
|