I have also tried the WPS API and it does not work either.
I know that the network interface is installed and working (at least a
little) because it will automatically connect to an open AP.
Arkady
"Milkas" <Mil...@discussions.microsoft.com> wrote in message
news:50256A32-8405-48C0...@microsoft.com...
* MSXML 6.0 is required and I have a component to install it.
* Network Provisioning Service, but I'm not sure if it is required.
* Wireless Zero Configuration
* WindowsXP-KB918997-v6-x86-ENU.exe installed.
* VS2005 runtime libraries (vcredist_x86.exe) installed.
* device drivers for my wireless card.
Can anyone tell me what I might be missing from this list.
"Milkas" <Mil...@discussions.microsoft.com> wrote in message
news:50256A32-8405-48C0...@microsoft.com...
Assuming the driver got installed correcly (you can check it out in
setupapi.log) it looks like you got all the components required to get this
working.
Am I right assuming you are running your app under Administrator account?
Otherwise, without proper user group setup, it will fail because of not
enough permission. (By default, only a user who is logged on as a member of
the Administrators group or the Network Configuration Operators group can
use the Native Wifi API).
Just before calling WlanSetProfile you may want to check if you got adequate
permissions though a call to WlanGetSecuritySettings.
Wondering if you tried calling Wireless provisioning service API to create
WiFI profile instead? Something like
IProvisioningProfileWireless::CreateProfile.
As has been mentioned in one post here, the following two components are
also nice to have to get WPS API working:
"Simple Network Management Protocol"
"Network Location Awareness Service"
Also, check if "Primitive: Wzcsvc" got into your image config.
If you are saying it works on XP Pro, did you try launching your app on XPe
image with DependencyWalker (Profile feature) running? If not, you amy want
t\o give it a try. Then you either see missing parts or you can compare it
to the same log captured on XP Pro machine. See if there is any difference
in the way how the API call stack works on both OSes.
Regards,
KM
can you please share the code to execute the Native Wifi API.I am getting error as error C2065: 'WlanOpenHandle' : undeclared identifier
Which header file i need to include and whar are the project settings that are required to be done?
You need the latest Windows Platform SDK, that contains wlanapi.h.
Will post a small example when I get to my PC.
Regards,
--PA
Regards,
--PA
------------- cut here ----------
// Usage: onoff.exe on|off
// pavel_a 04-jan-2007, built with Vista RTM SDK, vs2005
#include "stdafx.h"
#include <windows.h>
#include <wlanapi.h>
#pragma comment( lib, "wlanapi.lib")
#define tprintf _tprintf
static PTSTR rs2str( DOT11_RADIO_STATE rs )
{
switch(rs) {
case dot11_radio_state_on: return TEXT("on");
case dot11_radio_state_off: return TEXT("off");
default: return TEXT("undef");
}
}
static PTSTR ifstate2str( WLAN_INTERFACE_STATE rs )
{
switch(rs) {
default: return TEXT("undef");
case wlan_interface_state_not_ready: return TEXT("not_ready");
case wlan_interface_state_connected: return TEXT("connected");
case wlan_interface_state_ad_hoc_network_formed: return
TEXT("adhoc_formed");
case wlan_interface_state_disconnecting: return
TEXT("disconnecting");
case wlan_interface_state_disconnected: return TEXT("not
connected");
case wlan_interface_state_associating: return TEXT("associating");
case wlan_interface_state_discovering: return TEXT("discovering");
case wlan_interface_state_authenticating: return
TEXT("authenticating");
}
}
void OnOff( int a_on )
{
DWORD dwNegotiatedVersion = 0;
HANDLE hClient = NULL;
UINT i;
DWORD r;
PWLAN_INTERFACE_CAPABILITY pCapability = NULL;
PWLAN_INTERFACE_INFO_LIST pIntfList = NULL;
BOOL aenabled = FALSE, newstate = FALSE;
r = WlanOpenHandle( WLAN_API_VERSION, NULL, &dwNegotiatedVersion,
&hClient );
if( ERROR_SUCCESS != r )
{
tprintf( TEXT("Error opening Wlanapi=%u\n"), r );
return;
}
tprintf( _T("WlanAPI version available=%8.8x\n"), dwNegotiatedVersion );
r = WlanEnumInterfaces(hClient, NULL, &pIntfList);
if( ERROR_SUCCESS != r )
{
tprintf( TEXT("Error in WlanEnumInterfaces=%u\n"), r );
return;
}
for( i = 0; i < pIntfList->dwNumberOfItems; i++ )
{
PWLAN_INTERFACE_INFO pwi = &pIntfList->InterfaceInfo[i];
PWSTR descr = pwi->strInterfaceDescription;
GUID& guidIntf = pwi->InterfaceGuid;
WLAN_INTERFACE_STATE st = pwi->isState;
wprintf( TEXT("Adapter=[%s] state=%u (%s)\n"), descr, (UINT)st,
ifstate2str(st) );
if( st == wlan_interface_state_not_ready )
{
tprintf(TEXT("Interface not ready\n"));
continue;
}
ULONG outsize = 0;
PBOOL pb = NULL;
r = WlanQueryInterface( hClient, &guidIntf,
wlan_intf_opcode_autoconf_enabled, NULL, &outsize, (PVOID*)&pb, NULL );
if( ERROR_SUCCESS != r )
{
tprintf( TEXT("Error WlanQueryInterface(autoconf) =%u\n"), r );
continue;
}
aenabled = *pb & 0xFF;
WlanFreeMemory( pb );
tprintf( TEXT("Autoconfig enabled: %s\n"), aenabled ?
_T("yes"):_T("no") );
if( !a_on && aenabled )
{
newstate = 0; // FALSE
}
if( a_on && !aenabled )
{
newstate = 0xFF; // TRUE
}
r = WlanSetInterface( hClient, &guidIntf,
wlan_intf_opcode_autoconf_enabled, 4, (PVOID)&newstate, NULL );
if( r != ERROR_SUCCESS ) {
tprintf( TEXT("SetInterface error=%d\n"), r );
continue;
}
tprintf( TEXT("SetInterface ok\n") );
// NOTE: If the adapter was connected, it still stays connected;
// WZC just won't touch it any longer.
// We don't call WlanDisconnect because on XP this may convert an
// automatic profile to on-demand (see MSDN)
// After enabling WZC, you can restore connection manually,
// or call WlanConnect with some profile or SSID.
}//for
if (pIntfList != NULL) {
WlanFreeMemory(pIntfList);
}
if (hClient != NULL) {
WlanCloseHandle(hClient, NULL);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
if( !argv[1] ) return 1;
if( 0 == wcscmp( TEXT("off"), argv[1] ) ) {
OnOff( 0 );
} else if( 0 == wcscmp( TEXT("on"), argv[1] ) ) {
OnOff( 1 );
}
else return 2;
return 0;
}
----------- cut here -------------
"Pavel A." <pav...@NOfastmailNO.fm> wrote in message
news:eopnuYvT...@TK2MSFTNGP06.phx.gbl...
WirelessAutoConfigDlg.obj : error LNK2019: unresolved external symbol _WlanCloseHandle@8 referenced in function "public: void __thiscall CWirelessAutoConfigDlg::OnBnClickedButton1(void)" (?OnBnClickedButton1@CWirelessAutoConfigDlg@@QAEXXZ)
Although i have inclided the path of the lib file in the the Project roperties\Linker\General\Additional Library directeries.
I opened the lib and saw that these functions are present in the lib with the same name after being mangled.
What can be the possible reasons for the error.
Only WlanCloseHandle is unresolved and not others?
--PA
my profile is very simple:
<?xml version="1.0" ?>
<WLANProfile
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>NetTest1-adhoc</name>
<SSIDConfig>
<SSID>
<name>NetTest1</name>
</SSID>
</SSIDConfig>
<connectionType>IBSS</connectionType>
<MSM>
<security>
<authEncryption>
<authentication>open</authentication>
<encryption>NONE</encryption>
</authEncryption>
</security>
</MSM>
</WLANProfile>
Here is my code that i am using
void CWirelessAutoConfigDlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
HANDLE hClient = NULL;
DWORD dwError = ERROR_SUCCESS;
DWORD dwServiceVersion;
DWORD dwReason;
PWLAN_INTERFACE_INFO_LIST pIntfList = NULL;
CComPtr<IXMLDOMDocument2> pXmlDoc;
CComBSTR bstrXml;
VARIANT_BOOL vbSuccess;
HRESULT hr;
dwError = WlanOpenHandle(
WLAN_API_VERSION,
NULL, // reserved
&dwServiceVersion,
&hClient
);
dwError = WlanEnumInterfaces(hClient, NULL, &pIntfList);
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
// create a COM object to read the XML file
hr = CoCreateInstance(
CLSID_DOMDocument60,
NULL,
CLSCTX_INPROC_SERVER,
IID_IXMLDOMDocument2,
(void**)&pXmlDoc
);
CComVariant varFile;
varFile = "D:\\wirelessProfile3.xml";
hr = pXmlDoc->load(varFile, &vbSuccess);
hr = pXmlDoc->get_xml(&bstrXml);
dwError = WlanSetProfile(
hClient,
&pIntfList->InterfaceInfo[ 0 ].InterfaceGuid,
0, // no flags for the profile
bstrXml, //wsProfileXml,
NULL, // use the default ACL
TRUE, // overwrite a profile if it already exists
NULL, // reserved
&dwReason
);
dwError = WlanCloseHandle(
hClient,
NULL // reserved
);
}
Can you please help me out in finding the cause of the problem.Thanks in
advance.
Devika
From MSDN: "If this value is returned, pdwReasonCode specifies the
reason the profile is invalid." What is dwReason value on return?
--PA