PowerBuilder Requires Chilkat v11.7.0+
;S:;P:;; and offer to join the network. T is WPA (also used for WPA2 and WPA3), WEP, or nopass for an open network, and H:true can be added for a hidden network. In the name and the password, the characters backslash, semicolon, comma, colon and double quote must each be preceded by a backslash.
PowerBuilder
Create a Wi-Fi QR Code
See more QR Code Examples
Demonstrates a QR code that joins a phone to a Wi-Fi network when scanned. A QR code only holds text. Phones recognize text of the form WIFI:T:Chilkat PowerBuilder Downloads
integer li_rc
long li_Success
oleobject loo_Json
oleobject loo_Fmt
oleobject loo_JsonOut
li_Success = 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
if li_rc < 0 then
destroy loo_Json
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Json.UpdateString("payload.text","WIFI:T:WPA;S:Chilkat Guest;P:correct-horse-battery-staple;;")
// Level Q, so that the code still scans when it is printed small or gets worn.
loo_Json.UpdateString("encoding.qr.errorCorrection","Q")
loo_Json.UpdateInt("render.moduleSize",8)
// Say which network it is under the code.
loo_Json.UpdateBool("render.text.enabled",1)
loo_Json.UpdateString("render.text.value","Wi-Fi: Chilkat Guest")
loo_Json.UpdateInt("render.text.scale",2)
loo_Json.UpdateString("output.path","qa_output/qr_wifi.png")
loo_Json.UpdateBool("output.overwrite",1)
loo_Json.UpdateString("output.return","none")
loo_Fmt = create oleobject
li_rc = loo_Fmt.ConnectToNewObject("Chilkat.Formats")
loo_JsonOut = create oleobject
li_rc = loo_JsonOut.ConnectToNewObject("Chilkat.JsonObject")
li_Success = loo_Fmt.QrCode("generate",loo_Json,loo_JsonOut)
if li_Success = 0 then
Write-Debug loo_Fmt.LastErrorText
destroy loo_Json
destroy loo_Fmt
destroy loo_JsonOut
return
end if
Write-Debug "file: " + loo_JsonOut.StringOf("outputs[0].path")
Write-Debug "QR version: " + string(loo_JsonOut.IntOf("symbols[0].selectedEncoding.version"))
Write-Debug "image: " + string(loo_JsonOut.IntOf("outputs[0].width")) + " x " + string(loo_JsonOut.IntOf("outputs[0].height")) + " pixels"
// The image written to qa_output/qr_wifi.png:
//
// Sample output:
// file: qa_output/qr_wifi.png
// QR version: 5
// image: 360 x 374 pixels
destroy loo_Json
destroy loo_Fmt
destroy loo_JsonOut