Recent

Author Topic: WLanconnect XML wlan_connection_mode_temporary_profile  (Read 4083 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 844
WLanconnect XML wlan_connection_mode_temporary_profile
« on: November 11, 2021, 01:20:08 pm »
I use this to connect to a wifi AP and it works.


Code: Pascal  [Select][+][-]
  1. uses
  2. , nduWlanAPI, Windows, nduWlanTypes,
  3. procedure TForm1.Button1Click(Sender: TObject);
  4. var
  5. hClient: THandle;
  6. dwVersion: DWORD;
  7. ResultInt: DWORD;
  8. pInterface: Pndu_WLAN_INTERFACE_INFO_LIST;
  9. pConnectionParameters : tndu_WLAN_CONNECTION_PARAMETERS;
  10. Tvar : tndu_WLAN_CONNECTION_PARAMETERS;
  11. PConnectionParameters1 : pndu_WLAN_CONNECTION_PARAMETERS;
  12. pAvailableNetworkList: Pndu_WLAN_AVAILABLE_NETWORK_LIST;
  13. pInterfaceGuid: PGUID;
  14. begin
  15. ResultInt := WlanOpenHandle(1, nil, @dwVersion, @hClient);
  16. ResultInt := WlanEnumInterfaces(hClient, nil, @pInterface);
  17. pInterfaceGuid := @pInterface^.InterfaceInfo[pInterface^.dwIndex].InterfaceGuid; pConnectionParameters.wlanConnectionMode := WLAN_CONNECTION_MODE_PROFILE;     pConnectionParameters.strProfile := 'MySSID';
  18. pConnectionParameters.pDot11Ssid := nil;
  19. pConnectionParameters.pDesiredBssidList := nil;
  20. pConnectionParameters.dot11BssType := dot11_BSS_type_any;
  21. pConnectionParameters.dwFlags := 0;
  22. ResultInt := WlanConnect(hClient,
  23.                          pInterfaceGuid,
  24.                          @pConnectionParameters,
  25.                          nil);
  26. end;
  27.  

If I export the
to a XML file, using netsh wlan export profile name=MySSID, and change the connection mode to wlan_connection_mode_temporary_profile, how do I pass the XML to the WLanconnect function?
« Last Edit: November 11, 2021, 01:24:54 pm by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

Ulrich Wiesemann

  • Newbie
  • Posts: 2
Re: WLanconnect XML wlan_connection_mode_temporary_profile
« Reply #1 on: December 22, 2021, 05:11:36 pm »
Hello pcurtis,

I am unable to output the information from the pointers "pAvailableNetworkList" or "pConnectionParameters" in a memo. Can you write an example source code?

Gruß Ulrich

pcurtis

  • Hero Member
  • *****
  • Posts: 844
Re: WLanconnect XML wlan_connection_mode_temporary_profile
« Reply #2 on: December 22, 2021, 06:59:45 pm »
Hi there,i

not quite sure what you need, anyway the only source I have is attached above.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

Warfley

  • Hero Member
  • *****
  • Posts: 654
Re: WLanconnect XML wlan_connection_mode_temporary_profile
« Reply #3 on: December 22, 2021, 09:00:21 pm »
According to the documentation, this has to be done with the strProfile field of the WLAN_CONNECTION_PARAMETERS structure:
Quote
Specifies the profile being used for the connection.

If wlanConnectionMode is set to wlan_connection_mode_profile, then strProfile specifies the name of the profile used for the connection. If wlanConnectionMode is set to wlan_connection_mode_temporary_profile, then strProfile specifies the XML representation of the profile used for the connection. If wlanConnectionMode is set to wlan_connection_mode_discovery_secure or wlan_connection_mode_discovery_unsecure, then strProfile should be set to NULL.

pcurtis

  • Hero Member
  • *****
  • Posts: 844
Re: WLanconnect XML wlan_connection_mode_temporary_profile
« Reply #4 on: December 23, 2021, 06:16:54 am »
Yes, I've read that, but how?
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

Warfley

  • Hero Member
  • *****
  • Posts: 654
Re: WLanconnect XML wlan_connection_mode_temporary_profile
« Reply #5 on: December 23, 2021, 11:12:42 pm »
Well what did you try? I read that as if it should contain the XML content as string. Alternatively maybe pass the path to the XML file.

pcurtis

  • Hero Member
  • *****
  • Posts: 844
Re: WLanconnect XML wlan_connection_mode_temporary_profile
« Reply #6 on: December 25, 2021, 09:07:45 am »
@warfley See attached project
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

Ulrich Wiesemann

  • Newbie
  • Posts: 2
Re: WLanconnect XML wlan_connection_mode_temporary_profile
« Reply #7 on: December 26, 2021, 06:10:43 pm »
Many thanks for the quick response. As I spend the holidays with my family, I won't have time again until later!

 

TinyPortal © 2005-2018