; Note - this code is provided only to illustrate the syntax of calling methods in dpcom32.dll / dpcom64.dll.
; You should modify it to use the Dinkey Pro/FD Visual LISP API to best suit your own needs.
; See the Dinkey Pro/FD Manual for more information on how best to use the API to improve the level of protection.

(defun dpsample()
    (vl-load-com)                                                               ; You MUST call this command first, to load all external COM objects including dpcom32.dll or dpcom64.dll
  
    (setq dinkeyobject (vlax-create-object "DPro.DPro.2"))                      ; Get a reference to the Dinkey Pro object

    (setq retvalue (vlax-invoke-method dinkeyobject "InitDPCOM" "my_renamed_dpwin32or64.dll"))
    (if (= retvalue 0)                                                          ; Check the return value of intialisation
        (princ "Initialisation worked OK")                                      ; init successful
        (princ (strcat "Initialisation failed with error " (itoa retvalue)))    ; init failed - dll not in correct place, or wrong name specified?
    )
  
    (princ "\n")
  
    (setq retvalue (vlax-invoke-method dinkeyobject "ProtCheck" 0 0 ""))        ; Call this object's 'ProtCheck' method  
    (if (= retvalue 0)                                                          ; Check the return value of the protection check
        (princ "It worked!")                                                    ; Protection check successful
        (princ (strcat "Protection check failed with error " (itoa retvalue)))  ; Protection check failed, display an error message
    )

    (vlax-release-object dinkeyobject)                                          ; Release the Dinkey object reference

    (princ)
)
