|
-
Sep 27th, 2000, 03:18 AM
#1
Thread Starter
Addicted Member
Hi there,
I'm working on a program and I need to have a list of all coutrys in the world.
Windows already has this countrylist in it's system but I would like to know how to get a hold of it and put it in my own program.
I would also like to know if windows also keeps a country number with the name. Just like the netherlands has code 31 and the USA has code 840.
The last and maybe best question is: when I use the list from windows, should it show the list in the language that the windowsversion holds.
If you know any of these questions please contact me here or at [email protected]
Catch you later,
Jeroen Hoekemeijer
Code:
If 1 = 2 Then MajorError
-
Sep 27th, 2000, 04:21 AM
#2
I'd like that too... I'm searching and have only come up with this site so far... But I'll try to keep on searching...
Let me have a go, and maybe I can help ya...
-
Sep 27th, 2000, 08:15 AM
#3
Frenzied Member
hmmmmmmmm
I dunno. One problem is that the countries change every year or so. Hmmmmm. As far as getting the list, I don't think Windows has EVERY country on EARTH because thats about 250 or so, quite the list. Instead it uses the most large and computer-populated countries. Try messing w/ control panel in different areas. You may find what you need, but again, I dunno.
-
Sep 27th, 2000, 08:27 AM
#4
_______
<?>
'you can shell the Windows Dialog
Code:
Private Sub Command1_Click()
Shell "rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,0"
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 29th, 2000, 08:06 AM
#5
Thread Starter
Addicted Member
I've got the Country Code List RIGHT HERE!!!!
Realy nice that answer but it not what I ment.
So I have made my own system. It needs a lot af finetuning but the main key is there.
This code wil make an Array filled with the Number of a county and the name of the country. The only thing to do is put it under a combo or listbox.
Here's the code.
Option Explicit
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const HKEY_CURRENT_CONFIG = &H80000005
Private Const HKEY_CURRENT_USER = &H80000001
Private Const HKEY_DYN_DATA = &H80000006
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const HKEY_PERFORMANCE_DATA = &H80000004
Private Const HKEY_USERS = &H80000003
Private Const REG_BINARY = 3 ' Free form binary
Private Const REG_SZ = 1 ' Unicode nul terminated string
Private Const ERROR_SUCCESS = 0&
Private Const strSubKey As String = "Software\Microsoft\Windows\CurrentVersion\Telephony\Country List"
Private Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal cbName As Long) As Long
Private Sub Form_Load()
Dim strArray() As String
Dim SubKeys As Variant
Dim KeyLoop As Integer
Dim Data As String
SubKeys = GetAllKeys(HKEY_LOCAL_MACHINE, strSubKey)
If VarType(SubKeys) = vbArray + vbString Then
ReDim strArray(UBound(SubKeys), 1)
For KeyLoop = 0 To UBound(SubKeys)
strArray(KeyLoop, 0) = SubKeys(KeyLoop)
strArray(KeyLoop, 1) = Read_Reg_Value(strSubKey & "\" & SubKeys(KeyLoop), "Name")
Next
End If
ComboBox1.List = strArray
End Sub
Public Function GetAllKeys(hKey As Long, _
strPath As String) As Variant
Dim lRegResult As Long
Dim lCounter As Long
Dim hCurKey As Long
Dim strNames() As String
Dim strBuffer As String
Dim lDataBufferSize As Long
Dim intZeroPos As Integer
lCounter = 0
lRegResult = RegOpenKey(hKey, strPath, hCurKey)
Do
'initialise buffers (longest possible length=255)
lDataBufferSize = 255
strBuffer = String(lDataBufferSize, " ")
lRegResult = RegEnumKey(hCurKey, _
lCounter, strBuffer, lDataBufferSize)
If lRegResult = ERROR_SUCCESS Then
'tidy up string and save it
ReDim Preserve strNames(lCounter) As String
intZeroPos = InStr(strBuffer, Chr$(0))
If intZeroPos > 0 Then
strNames(UBound(strNames)) = Left$(strBuffer, intZeroPos - 1)
Else
strNames(UBound(strNames)) = strBuffer
End If
lCounter = lCounter + 1
Else
Exit Do
End If
Loop
GetAllKeys = strNames
End Function
Public Function Read_Reg_Value(strPath As String, strValue As String, Optional Default As String) As String
Dim lValueType As Long
Dim lResult As Long
Dim strBuffer As String
Dim lDataBufferSize As Long
Dim intZeroPos As Integer
Dim lRegResult As Long
Dim hCurKey As Long
If Not IsEmpty(Default) Then
Read_Reg_Value = Default
Else
Read_Reg_Value = ""
End If
lRegResult = RegOpenKey(HKEY_LOCAL_MACHINE, strPath, hCurKey)
lRegResult = RegQueryValueEx(hCurKey, strValue, 0&, lValueType, ByVal 0&, lDataBufferSize)
If lRegResult = ERROR_SUCCESS Then
If lRegResult = 0 Then
strBuffer = String(lDataBufferSize, " ")
lResult = RegQueryValueEx(hCurKey, strValue, 0&, 0&, ByVal strBuffer, lDataBufferSize)
intZeroPos = InStr(strBuffer, Chr$(0))
If intZeroPos > 0 Then
Read_Reg_Value = Left$(strBuffer, intZeroPos - 1)
Else
Read_Reg_Value = strBuffer
End If
End If
Else
MsgBox "A problem has occured"
End If
lRegResult = RegCloseKey(hCurKey)
End Function
Put it in your form and test it. It worked fin with my program.
Catch you later,
Jeroen Hoekemeijer
Code:
If 1 = 2 Then MajorError
-
Sep 29th, 2000, 10:54 AM
#6
http://www7.itu.int/bdt_cds/IDC/Countries.idc
These guys have a list of what seems to be the countries of the world. At least they've got some I've never heard of.
Tajikistan (????)
Good Luck
DerFarm
-
Sep 30th, 2000, 06:02 AM
#7
Thread Starter
Addicted Member
Well I'm sorry. Microoft has invented all these country's in the registary. So if microsoft supports them I suggest I do the same.
I'm happy with this list.
Catch you later,
Jeroen Hoekemeijer
Code:
If 1 = 2 Then MajorError
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|