Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dialing code
Message
 
To
01/10/2002 18:50:23
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00706628
Message ID:
00706721
Views:
26
>I have a phone field that i want to dial from it. if i have modem in my computer with com1 how in VFP i can set this field to dial from.
>
>Thanks

Or this code previously posted here:
#DEFINE GENERIC_READ  0x80000000
#DEFINE GENERIC_WRITE 0x40000000
#DEFINE CF_TEXT CHR(13) + CHR(10)

DEFINE CLASS Dialer AS CUSTOM
  nPort = 0

  FUNCTION DialNumber
  
    LPARAMETERS PhoneNumber, CommPort
  
    DECLARE INTEGER WriteFile IN Win32API;
      INTEGER hFile, STRING @lpbuffer,;
      INTEGER nNumberOfBytesToWrite,;
      INTEGER @lpNumberOfBytesWritten,;
      STRING @lpOverlapped

    DECLARE INTEGER CreateFile IN Win32API;
      STRING @lpFileName, INTEGER dwDesiredAccess,;
      INTEGER dwShareMode,;
      STRING @lpSecurityAttributes, INTEGER dwCreationDisposition,;
      INTEGER dwFlagsAndAttributes, INTEGER hTemplateFile

    DECLARE INTEGER FlushFileBuffers IN Win32API;
      INTEGER hFile

    DECLARE INTEGER GetLastError IN Win32API
    LOCAL lnport, lnwritten, lcmnd,lcport, lnresult

    lnresult = 0
    lcport = CommPort
    lnport = CreateFile(@lcport, GENERIC_READ + GENERIC_WRITE, 0, 0, 3, 0, 0)

    IF lnport > 0
      This.nPort = lnport
      lnwritten = 0
      lccmnd = "ATDT" + PhoneNumber + CF_TEXT
      IF WriteFile(lnport, @lccmnd, LEN(lccmnd), @lnwritten, 0) # 0
        * Flush the buffer to assure the data was written
        = FlushFileBuffers(lnport)
      ELSE
        lnresult = GetLastError()
      ENDIF
    ELSE
      lnresult = GetLastError()
    ENDIF
    RETURN lnresult
  ENDFUNC
  
  FUNCTION HangUp
  
    DECLARE INTEGER CloseHandle IN Win32API;
      INTEGER hObject
  
    LOCAL lccmnd, lnresult, lnport, lnwritten
    STORE 0 TO lnresult, lnwritten
    lnport = This.nPort
    lccmnd = 'ATH0' + CF_TEXT
    lnresult = WriteFile(lnport, @lccmnd, LEN(lccmnd), @lnwritten, 0)
    IF lnresult # 0
      FlushFileBuffers(lnport)
      *-- Close up
      CloseHandle(lnport)
    ELSE
      lnresult = GetLastError()
    ENDIF
    RETURN lnresult
  ENDFUNC

ENDDEFINE

*-- Example
SET PROCEDURE TO Dialer ADDITIVE
* Usage:
oDialier = CREATEOBEJECT('Dialer')
RELEASE PROCEDURE Dialer
IF oDialer # NULL
  ? oDialer.DialNumber('5555555', 'COM1')
  ? oDialer.HangUp()
ENDIF

Just an opinion... Not a fact.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform