Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use Windows Dialing Rules

Status
Not open for further replies.

wgcs

Programmer
Mar 31, 2002
2,056
EC
Any one know how to get the dialing rules from windows... or even better, perhaps through an API call, convert a plain 1-xxx-xxx-xxxx telephone number into a dialing string, where all the defined dialing rules for the current location have been applied?

(In Win2k you can set these options using Control Panel -> Phone and Modem Options -> Dialing Rules -> Locations, Edit)

Can any one explain how to get to these options on a WinXP machine, too? (I don't have one to play with...)
 
wgcs,

I'll answer here, cause I think you will be using this from VFP :)

It's just a Control Panel File (CPL), so you can simply call it using ShellExecute / WSH.Run

This code is tested on W2K. I don't know the filename for XP, just search for the CPL file.

ShellExecute(0, '', 'Control', 'Telephon.cpl', '', 1)

Hope that helps

-- AirCon --
 
AirCon

Just to confirm, it also works in XP.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
If you want to do it programatically, here's some code that I dredged up out of a long-lost project that does dialling:

Code:
* Program....: TAPI.INIT
* Version....: 1.0
* Author.....: Andrew Coates
* Date.......: December 10, 1998
* Notice.....: Copyright © 1998 Civil Solutions, All Rights Reserved.
* Compiler...: Visual FoxPro 06.00.8167.00 for Windows
* Abstract...: Wrapper for TAPI32.DLL calls. Currently only implements Assisted Telephony Functions
* Changes....:

* declare the functions 
declare integer tapiGetLocationInfo in tapi32.dll ;
	string @ cCountryCode, ;
	string @ cCityCode
declare integer tapiRequestMakeCall in tapi32.dll ;
	string @ cDestAddress, ;
	string @ cAppName, ;
	string @ cCalledParty, ;
	string @ cComment

* check that TAPI is installed by populating the country code and area code
local lnTAPIResult, lcCountryCode, lcCityCode, llTAPIInstalled
store repl(chr(0), TAPI_MAXCODELENGTH) to lcCountryCode, lcCityCode

lnTAPIResult = tapiGetLocationInfo(@lcCountryCode, @lcCityCode)

if lnTAPIResult < 0		&& call failed - assume TAPI's not installed
	llTAPIInstalled = .f.
else					&& call succeeded, put the results into properties
	llTAPIInstalled = .t.
	with this
		* The codes are everything up to but not including the first chr(0)
		.cCountryCode = left(lcCountryCode, at(chr(0), lcCountryCode) - 1)
		.cCityCode = left(lcCityCode, at(chr(0), lcCityCode) - 1)
	endwith
endif

return llTAPIInstalled

Andrew Coates
OzFox 2003 Australia's VFP Conference -- ------
DISCLOSURE
We are the Australasian Distributor for the Hentzenwerke Series of Books. (By the same token, I really do think they're the best printed VFP resource out there -- that's why we sell them)
 
Mike

Thanks for the confirmation. I just tested on ME, also work. So I think it runs on any Win-OS environment :)

-- AirCon --
 
Thanks, Everyone,

AirCon: That's a good way to provide a quick link to send my users to the place to configure the location. Now I just need to be able to apply those settings to an arbitrary phone number.

Andrew: That's a good start, but it only gets the Country Code and Area Code from Tapi: There's still the specific settings for when to use the area code/country code; What the set calling card is; What to dial to get an outside line, etc.

I'm using Exceletel TeleTools to control a voice Telephony device, and it dials exactly the numbers I give it... I could see if there is an equivalent of tapyRequestMakeCall that would let TAPI apply these rules just before making the call, but I wanted to be able to show the user what will be dialed in order to make the calls, so they can be confident that all the calls (to different area codes, etc) will go through unattended.

To have a starting point, I've paralleled the TAPI settings inside my program, and let the user set four things:
1) Dial this to get an outside line. (this can include calling card, or &quot;9,&quot; or be blank)
2) Country Code
3) Area Codes that Don't need the Country Code
4) Area Codes (or Area Code+Exchange) that don't need the area code (and hence, don't need the Country Code) to be dialed.

Anyone see any common situations that these four rules don't cover? (we are limiting it to dialing phone numbers in the format AAA-EEE-XXXX (A=area code, E=Exchange), and so will only work in countries that use this format phone numbers)
 
I started looking at other Tapi functions, and found lineTranslateDialog.

eg:
Code:
DECLARE LONG lineTranslateDialog IN Tapi32.dll ;
  INTEGER HLINEAPP_hLineApp,   ;
  LONG    DWORD_dwDeviceID,    ;
  LONG    DWORD_dwAPIVersion,  ;
  INTEGER HWND_hwndOwner,      ;
  STRING @ lpszAddressIn
lcPhn = &quot;+ (333) 1112222&quot; && Canonical format
xx = lineTranslateDialog(0,5,0x00020002,0,@lcPhn)

This is exactly what I was looking for... except that it shows a UI. It's okay for initial configuration, but then I need to translate many phone #'s without UI.
 
Aha: I found lineTranslationAddress which seems to be exactly what I want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top