La connexion semble reussir, l'appel a l'API INIT_connectToNonStandardServer retourne 0 (succes), mais il devrait peupler le parametre HarmServerHandle qui reste vide, le nombre de travaux d'impression trouves est toujours 0, et le tableau d'ID de travaux est toujours retourne vide. Si je me sers des memes appels en C++, il y a des travaux qui attendent. Il y a quelquechose que je ne dois pas envoyer correctement. Je me suis arrache les cheveux trop longtemps, et ma femme n'aprouve pas
► Afficher le texte
Code : Tout sélectionner
Dim $HARMRETOK = 0 ; valeur retournee lorsque le serveur est pret
Dim $IPAddress = "1.2.3.4"
Dim $User = "administrateur"
Dim $Password = "motDePasse"
; creer structures et pointeurs vers structures pour appels dessous
; typedef in C++:
;typedef struct{
; char *hostname ;
; char *username ;
; char *password ;
; int uid ;
; int timeout ;
; int trpc_version ;
; int backwards ;
; int dedicated_thread ;
; int encrypt ;
; const char *most_recent_function ; /* pointer to static string */
; int use_lpc ;
; void *new_bridge ;
; void *self_pointer ; /* for sanity checking */
;} HarmServerHandle ;
Const $tagServerhandle = "ptr hostname;ptr username;ptr password;int uid;int timeout;int trpc_version;int backwards;int dedicated_thread;int encrypt;ptr most_recent_function;int use_lpc;ptr new_bridge;ptr self_pointer"
Dim $structServerHandle = DllStructCreate ( $tagServerhandle )
Dim $p_ServerHandle = DllStructGetPtr($structServerHandle)
Dim $p_SessionHandle = GetEmptySessionHandlePtr()
Dim $NumOfjobs, $arJobIDs
Dim $DllHandle = DllOpen ( "C:\Common\harm.dll" )
Dim $HarmRes = ConnectToHarmNonStandard($DllHandle, $p_ServerHandle)
if $HarmRes = $HARMRETOK Then
$HarmRes = OpenSession($DllHandle, $p_ServerHandle, $p_SessionHandle)
if $HarmRes = $HARMRETOK Then
$HarmRes = GetNumOfJobs($DllHandle, $p_SessionHandle, $NumOfjobs)
if $HarmRes = $HARMRETOK Then
; ici, le nombre de travaux d'impression est toujours 0
MsgBox(262144,'Debug line ' & @ScriptLineNumber,'$NumOfjobs = ' & @lf & $NumOfjobs)
$HarmRes = GetJobs($DllHandle, $p_SessionHandle, $arJobIDs)
if $HarmRes = $HARMRETOK Then
; ici, le tableau de travaux est toujours vide
MsgBox(0,"","ubound($arJobIDs) = " & UBound($arJobIDs))
EndIf
EndIf
EndIf
DllCall ( $DllHandle, "none", "JOBM_CloseSession", _
"ptr", $p_SessionHandle, _
"ptr", GetEmptyHTicketPtr() _
)
EndIf
; -------------------
Func ConnectToHarmNonStandard($DllHnd, ByRef $p_SvrHnd)
Dim $Empty = DllStructCreate ( "char")
Dim $p_empty = DllStructGetPtr ( $Empty )
Dim $Prot = "trpc"
;C++ prototype: int32 MSWSTDCALL INIT_connectToNonStandardServer(const char *hostname,const char *username,const char *password,const char *protocol,int32 port,int32 trpc_version,int32 timeout_seconds,HarmServerHandle *handle,HarmNBTicket *nbticket) ;
;C++ actual call:
;int32 error;
;error = INIT_connectToNonStandardServer( m_vServerAddress, "admin", m_vPassord, "trpc", -1, /*0*/-1, -1, &serverH, NULL );
Dim $Ret = DllCall ( $DllHnd, "int", "INIT_connectToNonStandardServer", _
"char*", $IPAddress, _ ; nom hote
"char*", $User, _ ; nom utilisateur
"char*", $Password, _ ; mot de passe
"char*", $Prot, _ ; protocole
"int", -1, _ ; port
"int", -1, _ ; version protocole
"int", -1, _ ; delai max en secondes
"ptr", $p_SvrHnd, _ ; HarmServerHandle
"ptr", GetEmptyHTicketPtr() _;$p_HarmNBTicket
)
MsgBox(262144,'Debug line ' & @ScriptLineNumber,'$p_SvrHnd' & @lf & $HSH) ; toujours vide
Dim $Data = DllStructGetData($p_SvrHnd, 1) & "|" & DllStructGetData($p_SvrHnd, 2) & "|" & DllStructGetData($p_SvrHnd, 3)
MsgBox(262144,'Debug line ' & @ScriptLineNumber,'$Data' & @lf & $Data) ; toujours "0|0|0"
MsgBox(262144,'Debug line ' & @ScriptLineNumber,'$Ret' & @lf & $Ret)
return $Ret
EndFunc
Func GetEmptyHTicketPtr()
Const $tagHarmNBTicket = "int ID;ptr HarmServerHandle"
Return DllStructGetPtr ( DllStructCreate ( $tagHarmNBTicket ) )
EndFunc
Func GetEmptySessionHandlePtr()
Const $tagHarmSessionHandle = "int secure_handle;ptr HarmServerHandle"
Dim $structHarmSessionHandle = DllStructCreate ( $tagHarmSessionHandle )
Return DllStructGetPtr ( $structHarmSessionHandle )
EndFunc
Func GetJobs($DllHnd, $p_SessionHnd, ByRef $arJobIDs)
Dim $NumOfJobs = 100
Dim $arJobList = dllstructcreate("ptr[100]")
For $iItem = 0 to 99
Dim $JobIDStruct = DllStructCreate("Chr[256]")
DllStructSetData($arJobList, $iItem, DllStructGetPtr($JobIDStruct))
Next
Dim $p_arJobList = dllstructgetptr($arJobList)
;Description de l'API:
;Retourne une liste des travaux d'impression sur le serveur.
;Le tableau job_list doit etre cree et peuple de pointeurs vers des tampons pour les ID de travaux avant d'appeler cette fonction.
;prototype C:
;HarmResult JOBM_getJobList(
; HarmSessionHandle *session,
; int32 skip,
; int32 max,
; char **job_list /* [] */,
; int32 *num_jobs,
; HarmNBTicket *nbticket) ; /* trpc_function_prototype */
Dim $Ret = DllCall ( $DllHnd, "int", "JOBM_getJobList", _
"ptr", $p_SessionHnd, _
"int", 0, _
"int", 0, _
"ptr", $p_arJobList, _
"int*", $NumOfJobs, _
"ptr", GetEmptyHTicketPtr() _
)
$arJobIDs = DllStructGetData($p_arJobList, 1)
Return $Ret
EndFunc
Func GetNumOfJobs($DllHnd, $p_SessionHnd, ByRef $NumOfjobs)
Const $tagNumOfJobs = "int numOfJobs"
Dim $structNumObJobs = DllStructCreate ( $tagNumOfJobs )
Dim $NumOfJobsPtr = DllStructGetPtr ( $structNumObJobs )
;Description: Retourne le nombre total de travaux d'impression sur le serveur.
;prototype C:
;HarmResult JOBM_getNumJobs(
; HarmSessionHandle *session,
; int32 *num_jobs,
; HarmNBTicket *nbticket) ; /* trpc_function_prototype */
Dim $Ret = DllCall ( $DllHnd, "int", "JOBM_GetNumJobs", _
"ptr", $p_SessionHnd, _
"ptr", $NumOfJobsPtr, _
"ptr", GetEmptyHTicketPtr() _
)
$NumOfjobs = DllStructGetData($structNumObJobs, 1)
Return $Ret
EndFunc
Func OpenSession($DllHnd, ByRef $p_SvrHnd, ByRef $p_SessionHnd)
Return DllCall ( $DllHnd, "int", "JOBM_OpenSession", _
"ptr", $p_SvrHnd, _
"ptr", $p_SessionHnd, _
"ptr", GetEmptyHTicketPtr() _
)
EndFunc

