How to determine Fax Job Status

  • Thread starter Thread starter Tore Bostrup
  • Start date Start date
T

Tore Bostrup

I need to track the status of a submitted fax job from a VB6 app. In a post
by Raghavendra R of the Microsoft Printing, Imaging and Fax Team, the API is
required in order to determine the retry status (apparently the
FaxJob.QueueStatus will return UNKNOWN regardless of whether it is queued
for retry or failed permanently).
(http://groups.google.com/[email protected]&rnum
=2).

I have been looking for samples for monitoring fax jobs with the FaxGetJob
API, but Google only found 5 Web hits (2 for Fax SDK, 2 to a German site
with VB declarations, and 1 to an oriental language site) and 3 Groups hits,
one of which being the aforementioned post. Is nobody using the FAX
API...???

Does anyone have a (preferably VB) code snippet that successfully obtains a
Queue Status including JS_RETRIES_EXCEEDED?

TIA,
Tore.
 
Hi Tore,
I have been looking for samples for monitoring fax jobs with the FaxGetJob
API, but Google only found 5 Web hits (2 for Fax SDK, 2 to a German site
with VB declarations, and 1 to an oriental language site) and 3 Groups hits,
one of which being the aforementioned post. Is nobody using the FAX
API...???
Does anyone have a (preferably VB) code snippet that successfully
obtains a
Queue Status including JS_RETRIES_EXCEEDED?


I'm right in the development for this and it seems to be quite difficult
using VB6 for this. I need to deal with rtlmovememory and some other
tricks to get this to work - at the moment I'm earning many crashes.
However, I seem to get the first job in the queue from the api with
correct data using FaxEnumJobs.

Do you have the integer/long values for those status flags? I really
need them to get further, but I can't find winfax.h (where they should
be declared) on the net.

I'm willing to share part of my development if you can help me out with
this.

Regards,

Mathias Wuehrmann
 
I finally got it working. I have posted my code at
http://www.bostrup.us/swdev/vb6.htm.

Have at it - and feel free to comment on it. It has not been exhaustively
tested (far from it), but 10-15 tests on a couple of systems with very
little fax activity appeared successful - i.e. no crashes, unexpected
results or apparent stability in our app.

HTH,
Tore.
 
Hi Tore,
I finally got it working. I have posted my code at
http://www.bostrup.us/swdev/vb6.htm.
Have at it - and feel free to comment on it. It has not been exhaustively
tested (far from it), but 10-15 tests on a couple of systems with very
little fax activity appeared successful - i.e. no crashes, unexpected
results or apparent stability in our app.

seems like finally two VB6 programmers on the whole world worked out a
solution for our language independently :-)

You focused on the status values, while my focus lies on the whole
thing, also getting the extra information that is not available through
COM. The next thing I'll implement is the EventQueue, so my app will get
notified of status changes instead of using a timer to repeatly query if
any status has changed. This seems to be quite easy because windows
messages are used for this.

However, your solution is more tidied and I think I'll adapt this style ;-)

PS: Did you know that the Fax COM was really nice extended for Windows
XP fax service?

Regards,

Mathias Wuehrmann
 
Hello Mathias,

I would be interested in your EventQueue code - what I have is sufficient
for my upcoming demos. And I prefer to use the the Fax COM objects where
possible (such as sending the faxes, managing jobs, etc.), since the Fax API
requires messing with pointers and all the perils that entails. Also, I
don't have any performance issues that would require me to consider the API
(don't know if or how much faster it would be).

I have seen the documentation for the extended Fax COM objects (the XP
object model), but my current target is exclusively Win2k systems. In the
future, I see a Win2003 server as a more likely target (for my app) than the
XP, and if I understand correctly, the Windows 2003 server doesn't include
it?

PLEASE NOTE (if you use my code) that I detected an issue with my
CopyStringFromPtr function when testing manipulating the fax queue. When
obtaining the status of a particular item in the structure of a particular
job I would get a GPF on CopyMemory. The following code resolved that
specific case in my tests, but more testing (or alternative well-tested code
for the particular function) would be prudent. I have also uploaded the
change.

'***************************************************************************
****
'
' CopyStringFromPtr (FUNCTION)
'
' Author: Tore Bostrup
'
' Revision History:
' 18-Oct-2004 Initial Version
' 19-Oct-2004 Correction for GPF when copying a specific test item
' Resolved by reducing the initial and incremental "chunk"
' size to 4 bytes (i.e. lBuf = 16 : i = 2).
'
' Description:
' This function will copy a zero byte terminated ANSI string of unknown
' length into a VB String.
'
' Parameters:
' (In)
' lpctstrSource - Long A C++ LPCTSTR (pointer).
'
' Return Value:
' String - The resulting VB String.
'
'***************************************************************************
****
Private Function CopyStringFromPtr(ByVal lpctstrSource As Long) As String

Dim sBuf As String
Dim lBuf As Long
Dim i As Long
Dim lResLen As Long

If lpctstrSource = 0 Then
CopyStringFromPtr = ""
Else
'A GPF error occurred on a particular item after deleting some job
entries
'when attempting to copy 32 bytes (lBuf = 16 : i = 2).
'The GPF was resolved by reducing the initial and incremental size
copied
'to 4 bytes.
lBuf = 4
i = 1
sBuf = Space$(i * lBuf)
CopyMemory ByVal sBuf, ByVal lpctstrSource, Len(sBuf)
lResLen = InStr(sBuf, vbNullChar) - 1
Do While lResLen = -1
i = i + 1
sBuf = Space$(i * lBuf)
CopyMemory ByVal sBuf, ByVal lpctstrSource, Len(sBuf)
lResLen = InStr(sBuf, vbNullChar) - 1
Loop
sBuf = Left$(sBuf, InStr(sBuf, vbNullChar) - 1)
CopyStringFromPtr = sBuf
End If

End Function

HTH,
Tore.
 
helllpp

Hello Mr.

I am struggling to work out a working solution to send faxes
from my own appication using DllImports or FAXCOMLib on Windows 2000.

As anybody of us, I want to have a status for each of the sent/unsent fax items
on the query list. If you have any experiences, please let me know how would you
do this.

Regards,
Laszlo Varga

PS:
link: http://www.bostrup.us/swdev/vb6.htm doesnt functioning anymore
 
Back
Top