kiln said:
I'm not familiar with API calls to external programs. A program I
might need to interact with, Express Dictate, has a tiny SDK located
at
http://www.nch.com.au/express/sdk.html
So far I've not been able to blunder my way into a successful call to
this API.
[1] Most literature refers to calling dlls - this is an exe - does
that make any difference?
[2] The SDK ref'd above does list some examples but they are in C++,
which I'm not familiar with.
[3] Mininally I need to test for ver, open Express Dictate, and rename
the dictation. Those would be 0,1,5.
[4] Code I've tried so far (this is Access 2000)
Private Declare Function api_ExpressDictateVer Lib "C:\Program
Files\NCH Swift Sound\Express\express.exe" Alias
"EDAPISendCommandSimple(0)" ()
Public Function EDVer() As Integer
EDVer = api_ExpressDictateVer
End Function
Running EDVer gets me a "can't find DLL entry point..." error message.
I hope the solution to this is self-evident to someone. The call to
rename (5) will probably be the hard one, but is also the most
important for my purposes.
This is not my strong suit, but I think it will be something along these
lines:
'----- start of module code -----
Option Compare Database
Option Explicit
Private Declare Function FindWindowEx _
Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
ByVal lpsz1 As String, ByVal lpsz2 As String) _
As Long
Private Declare Function SendMessage _
Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) _
As Long
Private Declare Function GlobalAddAtom Lib "kernel32" _
Alias "GlobalAddAtomA" _
(ByVal lpString As String) As Long
Private Declare Function GlobalDeleteAtom Lib "kernel32" _
(ByVal nAtom As Long) As Long
Private Const EDAPI_WINDOWCAPTION As String = "Express Dictate"
Private Const WM_EDAPI_COMMAND As Long = &H7FFF
Function EDAPISendCommandString(lCommand As Long, szStringToSend As
String) _
As Long
Dim lAtomExtraInfo As Long
lAtomExtraInfo = GlobalAddAtom(szStringToSend)
EDAPISendCommandString = EDAPISendCommand(lCommand, lAtomExtraInfo)
Call GlobalDeleteAtom(lAtomExtraInfo)
End Function
Function EDAPIGetVersion() As Long
EDAPIGetVersion = EDAPISendCommandSimple(0&)
' Returns the current API version which is currently 1.
' If 0 is returned the API is not available.
' If 2 or above is returned please contact us for updated
documentation.
End Function
Function EDAPIOpen()
' Opens the Express Dictate window and brings it to the front.
EDAPISendCommandSimple 1&
End Function
Function EDAPIHide()
' Hides Express Dictate (minimizes it to the task bar).
EDAPISendCommandSimple 2&
End Function
Function EDAPIExit()
' Exits Express Dictate (quits - no further commands will be
accepted).
EDAPISendCommandSimple 3&
End Function
Function EDAPINew()
' Creates a new dictation and selects that file
EDAPISendCommandSimple 4&
End Function
Function EDAPIRename(szNewDictationName As String)
' Renames the current dictation
EDAPISendCommandString 5&, szNewDictationName
End Function
Function EDAPISetData(szData As String)
' Adds data to the dictation notes.
' Usually this should be in tagged xml form.
' eg. EDAPISetData("<caseno>123456</caseno>");
' As many data fields can be set as required.
' This data can be extracted from the sent dct files
' using etools
www.nch.com.au/etools if required.
EDAPISendCommandString 6&, szData
End Function
Function EDAPIGetUserID() As Long
' Returns the registration ID of the current user.
' The registration ID of each user will always be unique.
' Together with the file number, the user ID and
' file number can be used to uniquely identify any file
' in the system.
' The UserID is also included in the dct header. See
'
www.nch.com.au/etools for more.
EDAPIGetUserID = EDAPISendCommandSimple(7&)
End Function
Function EDAPIGetFileNo() As Long
' Returns the unique file ID of the current file.
' The FileNumber is also included in the dct header. See
'
www.nch.com.au/etools for more.
EDAPIGetFileNo = EDAPISendCommandSimple(8&)
End Function
Function EDAPISend()
' Sends the current dictation to the default recipient
EDAPISendCommandSimple 9&
End Function
Function EDAPIDelete()
' Deletes the current dictation
EDAPISendCommandSimple 10&
End Function
Function EDAPISendCommandSimple(lCommand As Long) As Long
EDAPISendCommandSimple = EDAPISendCommand(lCommand, 0&)
End Function
Function EDAPISendCommand(lCommand As Long, lExtraData As Long) _
As Long
Dim hwndIVM As Long
Dim lProcess As Long
hwndIVM = FindWindowEx(0&, 0&, 0&, EDAPI_WINDOWCAPTION)
If (hwndIVM = 0) Then
' Express Dictate is not running.
' Attempt to run it.
lProcess = Shell("C:\Program Files\NCH Swift
Sound\Express\express.exe")
If lProcess = 0 Then
MsgBox "Unable to start Express Dictate!"
Exit Function
Else
hwndIVM = FindWindowEx(0&, 0&, 0&, EDAPI_WINDOWCAPTION)
End If
End If
If (hwndIVM = 0) Then
' Express Dictate is *still* not running!
EDAPISendCommand = 0
Else
EDAPISendCommand = _
SendMessage(hwndIVM, WM_EDAPI_COMMAND, lCommand, lExtraData)
End If
End Function
'----- end of module code -----
I doubt very much that this is all correct, but I hope it's getting
close.