- //
- // Fonction d'exemple modifié
- //
-
- string num()
- {
- Tapi tapi = new Tapi();
- tapi.Initialize();
-
- Hashtable DeviceCaps;
- int deviceIDCell = -1;
- DeviceCaps = new Hashtable();
- string szPhoneNumber = "";
-
- for( int i = 0; i < tapi.NumDevices; i++ )
- {
- LINEDEVCAPS dc = new LINEDEVCAPS(1024);
- dc.Store();
- int dwVersion = tapi.NegotiateVersion(i);
- int ret = NativeTapi.lineGetDevCaps(tapi.hLineApp, i, dwVersion, 0, dc.Data);
- if ( ret < 0 )
- continue;
- if ( (LINEERR)ret == LINEERR.STRUCTURETOOSMALL )
- {
- dc.Data = new byte[dc.dwNeededSize];
- ret = NativeTapi.lineGetDevCaps(tapi.hLineApp, i, dwVersion, 0, dc.Data);
- }
- dc.Load();
-
- if (dc != null && dc.ProviderName == CellTSP.CELLTSP_PROVIDERINFO_STRING)
- {
- LINEADDRESSCAPS ac = new LINEADDRESSCAPS(1024);
- ac.Store();
- ret = NativeTapi.lineGetAddressCaps(tapi.hLineApp, i, 0, dwVersion, 0, ac.Data);
- ac.Load();
- szPhoneNumber = Encoding.Unicode.GetString(ac.Data, ac.dwAddressOffset, ac.dwAddressSize);
-
- ac = null;
- deviceIDCell = i;
- break;
- }
-
-
- }
-
-
- if (deviceIDCell == -1) // Not found
- MessageBox.Show("Could not find cellular line");
-
- tapi.Shutdown();
- return szPhoneNumber;
- }
//
// Fonction d'exemple modifié
//
string num()
{
Tapi tapi = new Tapi();
tapi.Initialize();
Hashtable DeviceCaps;
int deviceIDCell = -1;
DeviceCaps = new Hashtable();
string szPhoneNumber = "";
for( int i = 0; i < tapi.NumDevices; i++ )
{
LINEDEVCAPS dc = new LINEDEVCAPS(1024);
dc.Store();
int dwVersion = tapi.NegotiateVersion(i);
int ret = NativeTapi.lineGetDevCaps(tapi.hLineApp, i, dwVersion, 0, dc.Data);
if ( ret < 0 )
continue;
if ( (LINEERR)ret == LINEERR.STRUCTURETOOSMALL )
{
dc.Data = new byte[dc.dwNeededSize];
ret = NativeTapi.lineGetDevCaps(tapi.hLineApp, i, dwVersion, 0, dc.Data);
}
dc.Load();
if (dc != null && dc.ProviderName == CellTSP.CELLTSP_PROVIDERINFO_STRING)
{
LINEADDRESSCAPS ac = new LINEADDRESSCAPS(1024);
ac.Store();
ret = NativeTapi.lineGetAddressCaps(tapi.hLineApp, i, 0, dwVersion, 0, ac.Data);
ac.Load();
szPhoneNumber = Encoding.Unicode.GetString(ac.Data, ac.dwAddressOffset, ac.dwAddressSize);
ac = null;
deviceIDCell = i;
break;
}
}
if (deviceIDCell == -1) // Not found
MessageBox.Show("Could not find cellular line");
tapi.Shutdown();
return szPhoneNumber;
}