Juan Cruz
June 27th, 2001, 12:33 PM
Hello Everybody!!!
I need some help:
How do I get all the country codes from Windows I mean, the phone code.
I have to do a combo box with it.
I know I can do that with API, but I do NOT know how.
Can someone help me, please?
Thaks in advance
Kdev
June 27th, 2001, 02:49 PM
Make a new form with a sorted combo box named Combo1 then paste this code into the form.
private Type VBRASCTRYINFO
CountryCode as Long
CountryID as Long
CountryName as string
NextCountryID as Long
End Type
private Declare Function RasGetCountryInfo _
Lib "rasapi32.dll" Alias "RasGetCountryInfoA" _
(lpRasCtryInfo as Any, lpdwSize as Long) _
as Long
private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination as Any, Source as Any, byval Length as Long)
'_______________________________________________________________
private Function VBRasGetCountryInfo _
(clsCountryInfo as VBRASCTRYINFO) as Long
Dim b(511) as Byte, lpSize as Long, rtn as Long
Dim lPos as Long, strTemp as string, lngLen as Long
b(0) = 20
CopyMemory b(4), clsCountryInfo.CountryID, 4
lpSize = 512
rtn = RasGetCountryInfo(b(0), lpSize)
VBRasGetCountryInfo = rtn
If rtn <> 0 then Exit Function
CopyMemory clsCountryInfo.NextCountryID, b(8), 4
CopyMemory clsCountryInfo.CountryCode, b(12), 4
CopyMemory lPos, b(16), 4
lngLen = lpSize - lPos - 2
If lngLen > 0 then
strTemp = string(lngLen, 0)
CopyMemory byval strTemp, b(lPos), lngLen
End If
clsCountryInfo.CountryName = strTemp
End Function
private Sub Form_Load()
Dim lngID as Long, rtn as Long
Dim MyCountry as VBRASCTRYINFO
lngID = 1
Do
MyCountry.CountryID = lngID
rtn = VBRasGetCountryInfo(MyCountry)
Combo1.AddItem (MyCountry.CountryName & " (" & MyCountry.CountryCode & ")")
If rtn <> 0 then Exit Do
lngID = MyCountry.NextCountryID
Loop While lngID <> 0
Combo1.ListIndex = 0
End Sub
Code complements of PlatformVB
http://home.iprimus.com.au/billmcc/PlatformVB/dun/rasgetcountryinfo.htm
-K