Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Arbitrary precision fixed point demo using HIME (Huge Integer Math and Encryption)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Arbitrary precision fixed point demo using HIME (Huge Integer Math and Encryption)

    Code:
    '=========================================================================
    '                  Fixed point numbers demo
    '          Huge Integer Math and Encryption library dll
    '                   ( H I M E . d l l )
    '                 (C) 2002-2007 DevOTechS
    '                 e-mail: support at devotechs.com
    '
    '         Demo program to use HIME.dll with fixed point numbers
    '               HIME.dll can be downloaded from:
    '                      www.devotechs.com
    '
    '=========================================================================
    
    
    #PBFORMS CREATED
    #COMPILE EXE
    #DIM ALL
    
    '--------------------------------------------------------------------------------
    '   ** Includes **
    '--------------------------------------------------------------------------------
    #INCLUDE "HIME.inc"
    #PBFORMS BEGIN INCLUDES 
    '#RESOURCE "HIME_Fixed_Point_Demo.pbr"
    #IF NOT %DEF(%WINAPI)
        #INCLUDE "WIN32API.INC"
    #ENDIF
    #INCLUDE "PBForms.INC"
    #PBFORMS END INCLUDES
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    '   ** Globals **
    '--------------------------------------------------------------------------------
    GLOBAL ghDlg AS DWORD
    GLOBAL HiFP_Num1 AS STRING
    GLOBAL HiFP_Num2 AS STRING
    GLOBAL HiFP_Accuracy AS LONG
    GLOBAL HiFP_Accuracy_Zeroes AS STRING
    
    
    '--------------------------------------------------------------------------------
    '   ** Constants **
    '--------------------------------------------------------------------------------
    #PBFORMS BEGIN CONSTANTS 
    %IDD_DIALOG1        = 101
    %IDC_LABEL1         = 1001
    %IDC_LABEL2         = 1003
    %IDC_TEXT_NUM1      = 1002
    %IDC_LABEL3         = 1005
    %IDC_TEXT_NUM2      = 1004
    %IDC_LABEL4         = 1006
    %IDC_TEXT_RESULT    = 1007
    %IDC_BUTT_ADD       = 1008
    %IDC_BUTT_SUBTR     = 1009
    %IDC_BUTT_DIV       = 1010
    %IDC_BUTT_MUL       = 1011
    %IDC_LABEL5         = 1013
    %IDC_TEXT_ACC       = 1012
    %IDC_LABEL6         = 1014
    #PBFORMS END CONSTANTS
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    '   ** Declarations **
    '--------------------------------------------------------------------------------
    DECLARE SUB HiFP_Init
    DECLARE SUB HiFP_Division
    DECLARE SUB HiFP_Multiplication
    DECLARE SUB HiFP_Addition
    DECLARE SUB HiFP_Subtraction
    DECLARE SUB HiFP_SendNumbersToHIME
    DECLARE FUNCTION HiFP_GetNumberFromHIME(i AS LONG) AS STRING
    DECLARE FUNCTION HiFP_Integer2FixedPoint(Num AS STRING) AS STRING
    
    DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
    DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS DECLARATIONS
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    FUNCTION PBMAIN()
    
    
        
        ShowDIALOG1 %HWND_DESKTOP
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    '   ** CallBacks **
    '--------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG1Proc()
    
        SELECT CASE CBMSG
            CASE %WM_COMMAND
                SELECT CASE CBCTL
                    CASE %IDC_LABEL1
                    CASE %IDC_TEXT_NUM1
                    CASE %IDC_LABEL2
                    CASE %IDC_TEXT_NUM2
                    CASE %IDC_LABEL3
                    CASE %IDC_LABEL4
                    CASE %IDC_TEXT_RESULT
                    CASE %IDC_BUTT_ADD
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            HiFP_Addition
                        END IF
                    CASE %IDC_BUTT_SUBTR
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            HiFP_Subtraction
                        END IF
                    CASE %IDC_BUTT_DIV
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            HiFP_Division
                        END IF
                    CASE %IDC_BUTT_MUL
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            HiFP_Multiplication
                        END IF
                    CASE %IDC_TEXT_ACC
                    CASE %IDC_LABEL5
                    CASE %IDC_LABEL6
    
                END SELECT
        END SELECT
    
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    '   ** Dialogs **
    '--------------------------------------------------------------------------------
    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt AS LONG
    #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
        LOCAL hDlg AS DWORD
        LOCAL hFont1 AS DWORD
        LOCAL hFont2 AS DWORD
    
    
    
        DIALOG NEW hParent, "HIME Fixed Point Numbers Demo", 235, 254, 311, 194, _
            %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR _
            %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX OR %WS_CLIPSIBLINGS OR %WS_VISIBLE _
            OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, _
            %WS_EX_WINDOWEDGE OR %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR _
            %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
        CONTROL ADD LABEL, hDlg, %IDC_LABEL1, "Enter 2 decimal point numbers and " + _
            "select an operation", 6, 4, 298, 16, %WS_CHILD OR %WS_VISIBLE OR _
            %SS_CENTER OR %SS_SUNKEN, %WS_EX_LEFT OR %WS_EX_LTRREADING
        CONTROL ADD TEXTBOX, hDlg, %IDC_TEXT_NUM1, "1.123456", 4, 36, 170, 12
        CONTROL ADD LABEL, hDlg, %IDC_LABEL2, "Number 1", 4, 26, 64, 8
        CONTROL ADD TEXTBOX, hDlg, %IDC_TEXT_NUM2, "5.123456", 4, 62, 170, 12
        CONTROL ADD LABEL, hDlg, %IDC_LABEL3, "Number 2", 4, 52, 64, 8
        CONTROL ADD LABEL, hDlg, %IDC_LABEL4, "Result", 4, 80, 64, 8
        CONTROL ADD TEXTBOX, hDlg, %IDC_TEXT_RESULT, "TextBox3", 4, 92, 300, 94, _
            %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %WS_HSCROLL OR %WS_VSCROLL _
            OR %ES_LEFT OR %ES_MULTILINE OR %ES_AUTOHSCROLL, %WS_EX_CLIENTEDGE OR _
            %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR
        CONTROL ADD BUTTON, hDlg, %IDC_BUTT_ADD, "+", 180, 62, 20, 14, %WS_CHILD OR _
            %WS_VISIBLE OR %WS_TABSTOP OR %BS_TEXT OR _
            %BS_PUSHBUTTON OR %BS_CENTER OR %BS_VCENTER, %WS_EX_LEFT OR _
            %WS_EX_LTRREADING
        CONTROL ADD BUTTON, hDlg, %IDC_BUTT_SUBTR, "-", 202, 62, 20, 14, %WS_CHILD _
            OR %WS_VISIBLE OR %WS_TABSTOP OR %BS_TEXT OR _
            %BS_PUSHBUTTON OR %BS_CENTER OR %BS_BOTTOM, %WS_EX_LEFT OR _
            %WS_EX_LTRREADING
        CONTROL ADD BUTTON, hDlg, %IDC_BUTT_DIV, "/", 246, 62, 20, 14
        CONTROL ADD BUTTON, hDlg, %IDC_BUTT_MUL, "*", 224, 62, 20, 14, %WS_CHILD OR _
            %WS_VISIBLE OR %WS_TABSTOP OR %BS_TEXT OR _
            %BS_PUSHBUTTON OR %BS_CENTER OR %BS_TOP, %WS_EX_LEFT OR _
            %WS_EX_LTRREADING
        CONTROL ADD TEXTBOX, hDlg, %IDC_TEXT_ACC, "30", 180, 36, 34, 12
        CONTROL ADD LABEL, hDlg, %IDC_LABEL5, "Accuracy [digits]", 180, 26, 64, 8
        CONTROL ADD LABEL, hDlg, %IDC_LABEL6, "Operation", 180, 52, 64, 8
    
        hFont1 = PBFormsMakeFont("Courier New", 9, 400, %FALSE, %FALSE, %FALSE, %ANSI_CHARSET)
        hFont2 = PBFormsMakeFont("MS Sans Serif", 12, 700, %FALSE, %FALSE, %FALSE, %ANSI_CHARSET)
    
        CONTROL SEND hDlg, %IDC_TEXT_NUM1, %WM_SETFONT, hFont1, 0
        CONTROL SEND hDlg, %IDC_TEXT_NUM2, %WM_SETFONT, hFont1, 0
        CONTROL SEND hDlg, %IDC_TEXT_RESULT, %WM_SETFONT, hFont1, 0
        CONTROL SEND hDlg, %IDC_BUTT_ADD, %WM_SETFONT, hFont2, 0
        CONTROL SEND hDlg, %IDC_BUTT_SUBTR, %WM_SETFONT, hFont2, 0
        CONTROL SEND hDlg, %IDC_BUTT_DIV, %WM_SETFONT, hFont2, 0
        CONTROL SEND hDlg, %IDC_BUTT_MUL, %WM_SETFONT, hFont2, 0
        CONTROL SEND hDlg, %IDC_TEXT_ACC, %WM_SETFONT, hFont1, 0
    
    #PBFORMS END DIALOG
    
        ghDlg = hDlg    'Store dialog handle in global to preserve it
        HiFP_Init
        
        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
        
        DeleteObject hFont1
        DeleteObject hFont2
    
        FUNCTION = lRslt
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    ' Start of Fixed Point Numbers routines
    
    '--------------------------------------------------------------------------------
    'Convert from Fixed point (decimal) format to integer
    'This means that we reformat the decimal number so that the number of fractional
    'digits equal that specified in 'HiFP_Accuracy'.
    'Then we remove the decimal point.
    'Example:   Suppose that HiFP_Accuracy equals 4
    '   Input   Normalised  Output
    '   4       4.0000      40000
    '   4.12    4.1200      41200
    '   4.12345 4.1234      41234          
    FUNCTION HiFP_FixedPoint2Integer(Num AS STRING) AS STRING
        LOCAL Digits_Integer  AS STRING 
        LOCAL Digits_Fraction AS STRING 
    
        IF INSTR(Num, ".") > 0 THEN     
                '== Num contains a decimal point
            Digits_Integer  = PARSE$(Num, ".", 1)   'Get digits left of the decimal point
            Digits_Fraction = PARSE$(Num, ".", 2)   'Get digits right of the decimal point  
            
            SELECT CASE LEN(Digits_Fraction)
                CASE > HiFP_Accuracy
                        'More digits in fraction than current accuracy --> truncate fraction
                    Digits_Fraction = LEFT$(Digits_Fraction, HiFP_Accuracy)
    
                CASE < HiFP_Accuracy
                        'Less digits in fraction than current accuracy --> add zeroes
                    Digits_Fraction = LEFT$(Digits_Fraction & HiFP_Accuracy_Zeroes, HiFP_Accuracy)
                     
                CASE = 0    'Do nothing
                     
            END SELECT
              
        ELSE
                '== Num does not contain a decimal point
            Digits_Integer  = Num                   'Get digits left of the decimal point  (the entire number)
            Digits_Fraction = HiFP_Accuracy_Zeroes  'Get digits right of the decimal point (all zeroes here)
                
        END IF
    
            'Compose the normalised number
        FUNCTION = Digits_Integer & Digits_Fraction
    
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    'Convert from (ascii) integer to Fixed point (decimal) format
    'The input number (in decimal ascii integer format) is simply 'HiFP_Accuracy' times too big. 
    'Conversion is simply to insert a decimal point at the right place so that 
    'the number contains 'HiFP_Accuracy' digits right of the point.
    'Example:   Suppose that HiFP_Accuracy equals 4
    '   Input   Output  
    '   40000    4.0000      
    '   12       0.0012      
    '   412345  41.2345                
    FUNCTION HiFP_Integer2FixedPoint(Num AS STRING) AS STRING
        LOCAL Digits_Integer  AS STRING 
        LOCAL Digits_Fraction AS STRING 
        
            'Make sure that Num contains enough digits. If not, add leading zeroes
        IF LEN(Num) < (HiFP_Accuracy + 1) THEN
                'Add leading zeroes
            Num = STRING$(HiFP_Accuracy + 1 - LEN(Num), "0") + Num        
        END IF
    
            'Insert decimal point
        Digits_Integer  = LEFT$(Num, -HiFP_Accuracy)  
        Digits_Fraction = RIGHT$(Num, HiFP_Accuracy)  
        FUNCTION = Digits_Integer + "." + Digits_Fraction                
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    'Fetch all data from the input textboxes and store in variables
    SUB HiFP_GetDataFromTextboxes
        LOCAL Temp AS STRING
        
            'Get first number from textbox
        CONTROL GET TEXT ghDlg, %IDC_TEXT_NUM1 TO HiFP_Num1
    
            'Get first number from textbox
        CONTROL GET TEXT ghDlg, %IDC_TEXT_NUM2 TO HiFP_Num2
    
            'Get accuracy from textbox
        CONTROL GET TEXT ghDlg, %IDC_TEXT_ACC TO Temp
        HiFP_Accuracy = VAL(Temp)
        HiFP_Accuracy_Zeroes = STRING$(HiFP_Accuracy, "0")
        
        Temp = HiFP_Num1 + $CRLF + HiFP_Num2
    END SUB
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    'Do Fixed Point division
    SUB HiFP_Division
        LOCAL Temp AS STRING
        LOCAL Quot AS STRING
        
            'Fetch all data from the input textboxes and store in variables
        HiFP_GetDataFromTextboxes    
        
            'Normalise the 2 numbers
        HiFP_Num1 = HiFP_FixedPoint2Integer(HiFP_Num1)
        HiFP_Num2 = HiFP_FixedPoint2Integer(HiFP_Num2)
        
            'To keep the accuracy for the result, we must increase the accuracy of the dividend
        HiFP_Num1 = HiFP_Num1 + HiFP_Accuracy_Zeroes
            '.. and show them in the result box
        Temp =                "Num 1 integer format: " + $CRLF + HiFP_Num1
        Temp = Temp + $CRLF + "Num 2 integer format: " + $CRLF + HiFP_Num2
    
        
            'Store the decimal numbers in HIME
        HiFP_SendNumbersToHIME
    
            'Do the division
        hi_Div 1, 2, 3, 4   'Num1 \ Num2 --> Reg3 = quotient, Reg4 = Remainder
        
            'Get quotient from HIME
        Quot = HiFP_GetNumberFromHIME(3) 'Get quotient (still in integer form though)   
        Temp = Temp + $CRLF + "Quotient in integer format: " + $CRLF + Quot
    
            'Convert quotient back to fixed point format
        Quot = HiFP_Integer2FixedPoint(Quot)
        Temp = Temp + $CRLF + "Quotient in fixed point format: " + $CRLF + Quot
    
            'Show results in text box
        CONTROL SET TEXT ghDlg, %IDC_TEXT_RESULT, Temp
                            
    END SUB
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    'Do Fixed Point Addition
    SUB HiFP_Addition
        LOCAL Temp AS STRING
        LOCAL Additn AS STRING
        
            'Fetch all data from the input textboxes and store in variables
        HiFP_GetDataFromTextboxes    
        
            'Normalise the 2 numbers
        HiFP_Num1 = HiFP_FixedPoint2Integer(HiFP_Num1)
        HiFP_Num2 = HiFP_FixedPoint2Integer(HiFP_Num2)
        
    '        '.. and show them in the result box
        Temp =                "Num 1 integer format: " + $CRLF + HiFP_Num1
        Temp = Temp + $CRLF + "Num 2 integer format: " + $CRLF + HiFP_Num2
    
        
            'Store the decimal numbers in HIME
        HiFP_SendNumbersToHIME
    
            'Do the addition
        hi_Add 1, 2, 3      'Num1 + Num2 --> Reg3
        
            'Get result from HIME
        Additn = HiFP_GetNumberFromHIME(3) 'Get result (still in integer form though)   
        Temp = Temp + $CRLF + "Result in integer format: " + $CRLF + Additn
            
            'Convert result back to fixed point format
        Additn = HiFP_Integer2FixedPoint(Additn)
        Temp = Temp + $CRLF + "Result in fixed point format: " + $CRLF + Additn
    
            'Show results in text box
        CONTROL SET TEXT ghDlg, %IDC_TEXT_RESULT, Temp
                            
    END SUB
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    'Do Fixed Point Subtraction
    SUB HiFP_Subtraction
        LOCAL Temp AS STRING
        LOCAL Subtr AS STRING
        
            'Fetch all data from the input textboxes and store in variables
        HiFP_GetDataFromTextboxes    
        
            'Normalise the 2 numbers
        HiFP_Num1 = HiFP_FixedPoint2Integer(HiFP_Num1)
        HiFP_Num2 = HiFP_FixedPoint2Integer(HiFP_Num2)
        
    '        '.. and show them in the result box
        Temp =                "Num 1 integer format: " + $CRLF + HiFP_Num1
        Temp = Temp + $CRLF + "Num 2 integer format: " + $CRLF + HiFP_Num2
    
        
            'Store the decimal numbers in HIME
        HiFP_SendNumbersToHIME
    
            'Do the addition
        hi_Sub 1, 2, 3      'Num1 - Num2 --> Reg3
        
            'Get result from HIME
        Subtr = HiFP_GetNumberFromHIME(3) 'Get result (still in integer form though)   
        Temp = Temp + $CRLF + "Result in integer format: " + $CRLF + Subtr
            
            'Convert result back to fixed point format
        Subtr = HiFP_Integer2FixedPoint(Subtr)
        Temp = Temp + $CRLF + "Result in fixed point format: " + $CRLF + Subtr
    
            'Show results in text box
        CONTROL SET TEXT ghDlg, %IDC_TEXT_RESULT, Temp
                            
    END SUB
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    'Do Fixed Point Multiplication
    SUB HiFP_Multiplication
        LOCAL Temp AS STRING
        LOCAL Multi AS STRING
        
            'Fetch all data from the input textboxes and store in variables
        HiFP_GetDataFromTextboxes    
        
            'Normalise the 2 numbers
        HiFP_Num1 = HiFP_FixedPoint2Integer(HiFP_Num1)
        HiFP_Num2 = HiFP_FixedPoint2Integer(HiFP_Num2)
        
    '        '.. and show them in the result box
        Temp =                "Num 1 integer format: " + $CRLF + HiFP_Num1
        Temp = Temp + $CRLF + "Num 2 integer format: " + $CRLF + HiFP_Num2
    
        
            'Store the decimal numbers in HIME
        HiFP_SendNumbersToHIME
    
            'Do the multiplication
        hi_Mul 1, 2, 3      'Num1 * Num2 --> Reg3
        
            'Get result from HIME
        Multi = HiFP_GetNumberFromHIME(3) 'Get result (still in integer form though)   
        Temp = Temp + $CRLF + "Result in integer format: " + $CRLF + Multi
        
            'Result has the double accuracy of the 2 arguments.
            'First reduce accuracy to the specified accuracy
        Multi = LEFT$(Multi, -HiFP_Accuracy)
            
            'Convert result back to fixed point format
        Multi = HiFP_Integer2FixedPoint(Multi)
        Temp = Temp + $CRLF + "Result in fixed point format: " + $CRLF + Multi
    
            'Show results in text box
        CONTROL SET TEXT ghDlg, %IDC_TEXT_RESULT, Temp
                            
    END SUB
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    SUB HiFP_SendNumbersToHIME
        
            'Store the decimal numbers in HIME
        hi_PutReg HiFP_Num1, 1        
        hi_PutReg HiFP_Num2, 2
        
            'Convert from decimal to huge integer format
        hi_Dec2Huge 1, 1
        hi_Dec2Huge 2, 2
        
    END SUB
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    'Get the number in specified register from HIME.
    'Attention ! This number is converted to decimal in the same register.
    'So original register contents will be lost because of the format conversion
    FUNCTION HiFP_GetNumberFromHIME(i AS LONG) AS STRING
    
            'Convert from huge integer format to decimal
        hi_Huge2Dec i, i
        
            'Get the decimal numbers from HIME
        FUNCTION = hi_GetReg(i)
        
    END FUNCTION
    '--------------------------------------------------------------------------------
    
    '--------------------------------------------------------------------------------
    SUB HiFP_Init
    
        hi_RegClear 1
        hi_HIMEParams_LoadFromFile 1       'Load HIME parameters from file
            
            'Register HIME
        hi_PutReg("xxxxx-xxxxxxx", 1)  <-- Put your license key here      
        hi_Register 1
        
        
    END SUB
    '--------------------------------------------------------------------------------
    Eddy

  • #2
    This is HIME.inc

    Code:
    '====================================================================
    '                       Header file for:
    '                       H I M E . d l l
    '          Huge Integer Math and Encryption library dll
    '                            V 2.05
    '                 (C) 2002-2008 DevOTechS
    '                 e-mail: [email protected]
    '====================================================================
    
    '--------------------------------------------------------------------
    ' Constants
    
    'When calling 'hi_GetGlobalError', following bits might be set:
    %hi_ErrBit_Div                =      &h1  '1
    %hi_ErrBit_ModInv             =      &h2  '2
    %hi_ErrBit_GenerateRSAKeys    =      &h4  '3
    %hi_ErrBit_Sub                =      &h8  '4
    %hi_ErrBit_Encrypt_RSA        =     &h10  '5
    %hi_ErrBit_Decrypt_RSA        =     &h20  '6
    %hi_ErrBit_Encrypt_AES_CBC    =     &h40  '7 
    %hi_ErrBit_Decrypt_AES_CBC    =     &h80  '8
    %hi_ErrBit_Encrypt_AES_ECB    =    &h100  '9
    %hi_ErrBit_Decrypt_AES_ECB    =    &h200  '10
    %hi_ErrBit_Encrypt_AES_1Block =    &h400  '11
    %hi_ErrBit_Decrypt_AES_1Block =    &h800  '12
    %hi_ErrBit_Base642Huge        =   &h1000  '13
    %hi_ErrBit_DiffieHellman      =   &h2000  '14
    %hi_ErrBit_ConcatByte         =   &h4000  '15
    %hi_ErrBit_EnDecrypt_Arc4     =   &h8000  '16
    %hi_ErrBit_Rec_GetField       =  &h10000  '17
    %hi_ErrBit_Rec_GetNrFields    =  &h20000  '18
    %hi_ErrBit_RegAllocRange      =  &h40000  '19
    %hi_ErrBit_CompDecompress     =  &h80000  '20
    %hi_ErrBit_FileError          = &h100000  '21
    %hi_ErrBit_BitManipulation    = &h200000  '22                                
    %hi_ErrBit_RootN              = &h400000  '23
    %hi_ErrBit_HMAC               = &h800000  '24
    
    
    'Constants for hi_SetOption and hi_GetOption
    %hi_Opt_NrPrimes        = 1     '1 : number of primes that are currently stored in HIMEs prime number table
    %hi_Opt_NrRegisters     = 2     '2 : the number of HIME registers
    %hi_Opt_Kara_Thresh_mul = 3     '3 : the Karatsuba threshold value for hi_mul (multiplication).
    %hi_Opt_Kara_Thresh_sq  = 4     '4 : the Karatsuba threshold value for hi_square (squaring).
    %hi_Opt_Zlib_Handle     = 5     '5 : the HIME_Zlib.dll handle.  
    %hi_Opt_JCalg1_handle   = 6     '6 : the HIME_JCalg1.dll handle.
    %hi_Opt_Endianness      = 7     '7 : the endianness. Used for HMAC
    %hi_Opt_Reverse         = 8     '8 : for reversing hash data. Used for HMAC
    
    
    'Constants for hi_HMAC_FIPS198a
    %hi_HMAC_Hash_MD5    = 1
    %hi_HMAC_Hash_SHA1   = 2
    %hi_HMAC_Hash_SHA256 = 3
    %hi_HMAC_Hash_SHA512 = 4
    
    
    'Constants for Synchronous/Asynchronous functions
    %hi_Command_Start_Sync  = 1
    %hi_Command_Start_Async = 2
    %hi_Command_Abort       = 3
    
    '--------------------------------------------------------------------
    
    
    '--------------------------------------------------------------------
    ' Declarations                                  
    DECLARE FUNCTION hi_Add                      LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        ,      lReg_Result AS LONG)    AS LONG                                                               
    DECLARE FUNCTION hi_And                      LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        , lReg_Result AS LONG) AS LONG
    DECLARE FUNCTION hi_Base642Huge              LIB "HIME.dll"( lRegIn AS LONG       , lRegOut AS LONG      ) AS LONG
    DECLARE FUNCTION hi_Bin2Huge                 LIB "HIME.dll"( lRegIn AS LONG       , lRegOut AS LONG      ) AS LONG
    DECLARE FUNCTION hi_BitClear                 LIB "HIME.dll"( Bitnr AS LONG        , lReg1 AS LONG        , lReg_Result AS LONG) AS LONG
    DECLARE FUNCTION hi_BitSet                   LIB "HIME.dll"( Bitnr AS LONG        , lReg1 AS LONG        , lReg_Result AS LONG) AS LONG
    DECLARE FUNCTION hi_BitToggle                LIB "HIME.dll"( Bitnr AS LONG        , lReg1 AS LONG        , lReg_Result AS LONG) AS LONG
    DECLARE FUNCTION hi_BreakString              LIB "HIME.dll"( lRegIn AS LONG       , CharsInChunk AS LONG ,      NrOfSpaces AS LONG ,    ChunksInLine AS LONG,    lReg_Result AS LONG) AS LONG       
    DECLARE FUNCTION hi_CheckTestVectors_AES     LIB "HIME.dll" AS LONG
    DECLARE FUNCTION hi_CheckTestVectors_Arc4    LIB "HIME.dll" AS LONG
    DECLARE FUNCTION hi_CheckTestVectors_HMAC_FIPS198  LIB "HIME.dll" AS LONG
    DECLARE FUNCTION hi_CheckTestVectors_MD5     LIB "HIME.dll" AS LONG
    DECLARE FUNCTION hi_CheckTestVectors_SHA_1   LIB "HIME.dll" AS LONG                                                                                                                                                                  
    DECLARE FUNCTION hi_CheckTestVectors_SHA_256 LIB "HIME.dll" AS LONG
    DECLARE FUNCTION hi_CheckTestVectors_SHA_512 LIB "HIME.dll" AS LONG                                                                                                                                                                  
    DECLARE FUNCTION hi_Compress                 LIB "HIME.dll"( lRegIn AS LONG       , Algo AS LONG         , lRegOut AS LONG) AS LONG
    DECLARE FUNCTION hi_CopyReg                  LIB "HIME.dll"( lRegSource AS LONG   , lRegTarget AS LONG   )      AS LONG                                                                                         
    DECLARE FUNCTION hi_Dec2Huge                 LIB "HIME.dll"( lRegIn AS LONG       , lRegOut AS LONG      )      AS LONG                                                                                         
    DECLARE FUNCTION hi_Decompress               LIB "HIME.dll"( lRegIn AS LONG       , lRegOut AS LONG) AS LONG
    DECLARE FUNCTION hi_Decr                     LIB "HIME.dll"( lReg1 AS LONG        , lReg_Result AS LONG  ) AS LONG
    DECLARE FUNCTION hi_Decrypt_AES_1Block       LIB "HIME.dll"( lReg_Cipher AS LONG  , lReg_Key AS LONG     ,      lReg_Plain AS LONG )    AS LONG                                                               
    DECLARE FUNCTION hi_Decrypt_AES_CBC          LIB "HIME.dll"( lReg_Cipher AS LONG  , lReg_Key AS LONG     ,      lReg_Plain AS LONG )    AS LONG                                                               
    DECLARE FUNCTION hi_Decrypt_AES_ECB          LIB "HIME.dll"( lReg_Cipher AS LONG  , lReg_Key AS LONG     ,      lReg_Plain AS LONG )    AS LONG                                                               
    DECLARE FUNCTION hi_Decrypt_Arc4             LIB "HIME.dll"( lReg_Cipher AS LONG  , lReg_Key AS LONG     ,      lReg_Plain AS LONG , BytesToDiscard AS LONG)     AS LONG
    DECLARE FUNCTION hi_Decrypt_RSA              LIB "HIME.dll"( lReg_Cipher AS LONG  , lReg_hd AS LONG      ,      lReg_hModul AS LONG,    lReg_Plain AS LONG  )    AS LONG                                      
    DECLARE FUNCTION hi_Decrypt_RSA_CRT          LIB "HIME.dll"( lReg_Cipher AS LONG  , lReg_p AS LONG       , lReg_q AS LONG, _
                lReg_dp AS LONG, lReg_dq AS LONG, lReg_PInvQ AS LONG, lReg_Plain AS LONG) AS LONG
    DECLARE FUNCTION hi_DH_GenParams             LIB "HIME.dll"( lBitLength AS LONG   , lRegP AS LONG        ,      lRegG AS LONG      )    AS LONG
    DECLARE FUNCTION hi_DH_Step1                 LIB "HIME.dll"( lRegP AS LONG        , lRegG AS LONG        ,      lPriv AS LONG      ,    lPub AS LONG) AS LONG
    DECLARE FUNCTION hi_DH_Step2                 LIB "HIME.dll"( lRegP AS LONG        , lPub AS LONG         ,      lPriv AS LONG      , lShared AS LONG) AS LONG
    DECLARE FUNCTION hi_Div                      LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        ,      lReg_Quot AS LONG  ,    lReg_Rem AS LONG    )    AS LONG                                      
    DECLARE FUNCTION hi_Div_V1                   LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        ,      lReg_Quot AS LONG  ,    lReg_Rem AS LONG    )    AS LONG
    DECLARE FUNCTION hi_DivBy2                   LIB "HIME.dll"( lReg1 AS LONG        , lReg_Quot AS LONG    ,      lReg_Rem AS LONG   )    AS LONG                                                               
    DECLARE FUNCTION hi_Encrypt_AES_1Block       LIB "HIME.dll"( lReg_Plain AS LONG   , lReg_Key AS LONG     ,      lReg_Cipher AS LONG)    AS LONG                                                               
    DECLARE FUNCTION hi_Encrypt_AES_CBC          LIB "HIME.dll"( lReg_Plain AS LONG   , lReg_Key AS LONG     ,      lReg_IV AS LONG    ,    lReg_Cipher AS LONG )    AS LONG                                      
    DECLARE FUNCTION hi_Encrypt_AES_ECB          LIB "HIME.dll"( lReg_Plain AS LONG   , lReg_Key AS LONG     ,      lReg_Cipher AS LONG)    AS LONG                                                               
    DECLARE FUNCTION hi_Encrypt_Arc4             LIB "HIME.dll"( lReg_Plain AS LONG   , lReg_Key AS LONG     ,      lReg_Cipher AS LONG, BytesToDiscard AS LONG )    AS LONG
    DECLARE FUNCTION hi_Encrypt_RSA              LIB "HIME.dll"( lReg_Plain AS LONG   , lReg_he AS LONG      ,      lReg_hModul AS LONG,    lReg_Cipher AS LONG )    AS LONG                                      
    DECLARE FUNCTION hi_ExtEuclidAlgo            LIB "HIME.dll"( lReg_A AS LONG       , lReg_B AS LONG       , ForcePositiveResults AS LONG, lReg_GCD AS LONG, lReg_x AS LONG, lReg_y AS LONG, Sign_x AS LONG, Sign_y AS LONG) AS LONG
    DECLARE FUNCTION hi_Factor_Pollards_Rho      LIB "HIME.dll"(lReg_N AS LONG, lReg_x0 AS LONG, lm AS LONG, lReg_c AS LONG, lReg_Command AS LONG, lReg_Status AS LONG, lReg_g AS LONG) AS LONG
    DECLARE FUNCTION hi_Factor_TrialDiv          LIB "HIME.dll"(lReg1 AS LONG, lP1 AS LONG, lP2 AS LONG, lReg_Result AS LONG) AS LONG
    DECLARE FUNCTION hi_Factors                  LIB "HIME.dll"(lReg_N AS LONG, lReg_Command AS LONG, lReg_Status AS LONG, lReg_Factors AS LONG) AS LONG
    DECLARE FUNCTION hi_FormatAsHuge             LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG) AS LONG
    DECLARE FUNCTION hi_GCD                      LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        ,      lReg_Result AS LONG)    AS LONG                                                               
    DECLARE FUNCTION hi_GenerateBBSRandomBits    LIB "HIME.dll"( lBytes AS LONG       , lMultipleBits AS LONG,      lReg_SSeed AS LONG ,    lReg_Modul AS LONG  ,    lReg_Result AS LONG,    lReg_ESeed AS LONG  )    AS LONG  
    DECLARE FUNCTION hi_GeneratePrime            LIB "HIME.dll"( lLengthBits AS LONG  , lPrimeTests AS LONG  ,      lReg_Result AS LONG)    AS LONG                                                               
    DECLARE FUNCTION hi_GenerateRandom           LIB "HIME.dll"( lLengthBits AS LONG  , lReg_Result AS LONG  )      AS LONG                                                                                         
    DECLARE FUNCTION hi_GenerateRSAKeys          LIB "HIME.dll"( lBitLength AS LONG   , lPrimeTests AS LONG  ,      lReg_he AS LONG    ,    lReg_hd AS LONG     ,    lReg_Modul AS LONG )    AS LONG            
    DECLARE FUNCTION hi_GenerateRSAKeys_CRT      LIB "HIME.dll"( lBitLength AS LONG   , lPrimeTests AS LONG  ,      lReg_he AS LONG, lReg_Modul AS LONG, _
             lReg_hp AS LONG, lReg_hq AS LONG, lReg_hdp AS LONG, lReg_hdq AS LONG, lReg_hPInvQ AS LONG) AS LONG
    DECLARE FUNCTION hi_GenerateRSARandomBits    LIB "HIME.dll"( lBytes AS LONG       , lReg_SSeed AS LONG   ,      lReg_he AS LONG    ,    lReg_Modul AS LONG  ,    lReg_Result AS LONG,    lReg_EndSeed AS LONG)    AS LONG  
    DECLARE FUNCTION hi_GetGlobalError           LIB "HIME.dll" AS LONG                                                                                                                                                                  
    DECLARE FUNCTION hi_GetOption                LIB "HIME.dll"( lOption AS LONG      , lParam AS LONG) AS LONG
    DECLARE FUNCTION hi_GetPrimeFromTable        LIB "HIME.dll"(lIndex AS LONG, lReg_Result AS LONG) AS LONG
    DECLARE FUNCTION hi_GetRandomBytesFromServer LIB "HIME.dll"( Server_ AS LONG      , Port_ AS LONG        , Command AS LONG      , TimeOut_ AS LONG        , NumberBytes AS LONG    , lReg AS LONG) AS LONG
    DECLARE FUNCTION hi_GetReg                   LIB "HIME.dll"( lReg AS LONG         ) AS                    STRING                                                                                                                  
    DECLARE FUNCTION hi_GetRegAdd                LIB "HIME.dll"( lReg AS LONG         , lAddress AS LONG     ,      lLen AS LONG       )    AS LONG                                                               
    DECLARE FUNCTION hi_GetRegAdd2               LIB "HIME.dll"( lReg AS LONG         , lAddress AS LONG) AS LONG
    DECLARE FUNCTION hi_GetRegAsciiz1            LIB "HIME.dll"( lReg AS LONG) AS LONG
    DECLARE FUNCTION hi_GetRegAsciiz2            LIB "HIME.dll"( lReg AS LONG         , azData AS ASCIIZ     ) AS LONG
    DECLARE FUNCTION hi_GetRegByte               LIB "HIME.dll"( lReg AS LONG         , index AS LONG) AS LONG
    DECLARE FUNCTION hi_GetRegDword              LIB "HIME.dll"(lReg AS LONG) AS DWORD
    DECLARE FUNCTION hi_GetRegLong               LIB "HIME.dll"(lReg AS LONG) AS LONG
    DECLARE FUNCTION hi_GetRegToClipboard        LIB "HIME.dll"( lReg AS LONG) AS LONG
    DECLARE FUNCTION hi_GetRegToFile             LIB "HIME.dll"( lReg AS LONG         , Mode AS LONG         , lReg_FileName AS LONG) AS LONG
    DECLARE FUNCTION hi_Hash_CRC32               LIB "HIME.dll"( lRegIn AS LONG       , lRegOut AS LONG) AS LONG
    DECLARE FUNCTION hi_Hash_MD5                 LIB "HIME.dll"( lRegIn AS LONG       , lRegOut AS LONG) AS LONG
    DECLARE FUNCTION hi_Hash_SHA_1               LIB "HIME.dll"( lRegIn AS LONG       , lRegOut AS LONG      ) AS LONG
    DECLARE FUNCTION hi_Hash_SHA_256             LIB "HIME.dll"( lRegIn AS LONG       , lRegOut AS LONG      )      AS                  LONG                                                                                         
    DECLARE FUNCTION hi_Hash_SHA_512             LIB "HIME.dll"( lRegIn AS LONG       , lRegOut AS LONG      )      AS                  LONG
    DECLARE FUNCTION hi_Hex2Huge                 LIB "HIME.dll"( lRegIn AS LONG       , lRegOut AS LONG      )      AS                  LONG
    DECLARE FUNCTION hi_HIMEParams_LoadFromFile  LIB "HIME.dll"(lReg_FileName AS LONG) AS LONG
    DECLARE FUNCTION hi_HIMEParams_SaveToFile    LIB "HIME.dll"(lReg_FileName AS LONG) AS LONG
    DECLARE FUNCTION hi_HMAC_FIPS198             LIB "HIME.dll"(lReg_Key AS LONG, lReg_Message AS LONG, lB AS LONG, lAlgo AS LONG, lReg_HMAC AS LONG) AS LONG
    DECLARE FUNCTION hi_Huge2Base64              LIB "HIME.dll"( lRegIn AS LONG       , lRegOut AS LONG      )      AS                  LONG
    DECLARE FUNCTION hi_Huge2Bin                 LIB "HIME.dll"( lRegIn AS LONG       , lRegOut AS LONG      )      AS                  LONG                                                                                         
    DECLARE FUNCTION hi_Huge2Dec                 LIB "HIME.dll"( lRegIn AS LONG       , lRegOut AS LONG      )      AS                  LONG                                                                                         
    DECLARE FUNCTION hi_Huge2Hex                 LIB "HIME.dll"( lRegIn AS LONG       , lRegOut AS LONG      )      AS                  LONG                                                                                         
    DECLARE FUNCTION hi_Incr                     LIB "HIME.dll"( lReg1 AS LONG        , lReg_Result AS LONG  ) AS LONG
    DECLARE FUNCTION hi_InitBBS                  LIB "HIME.dll"( lBitLength AS LONG   , lPrimeTests AS LONG  ,      lReg_Modul AS LONG ,    lReg_Seed AS LONG   )    AS LONG                                      
    DECLARE FUNCTION hi_IsBitSet                 LIB "HIME.dll"( Bitnr AS LONG        , lReg1 AS LONG) AS LONG
    DECLARE FUNCTION hi_IsEqual                  LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        )      AS                  LONG                                                                                         
    DECLARE FUNCTION hi_IsLess                   LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        )      AS                  LONG                                                                                         
    DECLARE FUNCTION hi_IsNotEqual               LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        )      AS                  LONG                                                                                         
    DECLARE FUNCTION hi_IsOdd                    LIB "HIME.dll"( lReg1 AS LONG        ) AS                    LONG                                                                                                                    
    DECLARE FUNCTION hi_IsPrime_Div              LIB "HIME.dll"( lReg1 AS LONG        ) AS                    LONG                                                                                                                    
    DECLARE FUNCTION hi_IsPrime_F                LIB "HIME.dll"( lTests AS LONG       , lReg1 AS LONG        )      AS                  LONG                                                                                         
    DECLARE FUNCTION hi_IsPrime_RB               LIB "HIME.dll"( lTests AS LONG       , lReg1 AS LONG        )      AS                  LONG                                                                                         
    DECLARE FUNCTION hi_IsPrime_Slow             LIB "HIME.dll"( lReg1 AS LONG        ) AS                    LONG                                                                                                                    
    DECLARE FUNCTION hi_IsRegAllocated           LIB "HIME.dll"( lReg AS LONG) AS LONG
    DECLARE FUNCTION hi_IsRelPrime               LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        )      AS                  LONG                                                                                         
    DECLARE FUNCTION hi_IsZero                   LIB "HIME.dll"( lReg1 AS LONG        ) AS                    LONG                                                                                                                    
    DECLARE FUNCTION hi_Mod                      LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        ,      lReg_Result AS LONG)    AS                   LONG                                                               
    DECLARE FUNCTION hi_ModInv                   LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        ,      lReg_Result AS LONG)    AS                   LONG                                                               
    DECLARE FUNCTION hi_Mul                      LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        ,      lReg_Result AS LONG)    AS                   LONG                                                               
    DECLARE FUNCTION hi_MulBy2                   LIB "HIME.dll"( lReg1 AS LONG        , lReg_Result AS LONG  )      AS                  LONG                                                                                         
    DECLARE FUNCTION hi_Not                      LIB "HIME.dll"( lReg1 AS LONG        , lReg_Result AS LONG  ) AS LONG
    DECLARE FUNCTION hi_Or                       LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        , lReg_Result AS LONG) AS LONG
    DECLARE FUNCTION hi_Pow                      LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        ,      lReg_Result AS LONG)    AS                   LONG                                                               
    DECLARE FUNCTION hi_PowMod                   LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        ,      lReg3 AS LONG      ,    lReg_Result AS LONG )    AS LONG                                      
    DECLARE FUNCTION hi_PutReg                   LIB "HIME.dll"( h AS STRING          , lReg AS LONG         )      AS                  LONG                                                                                         
    DECLARE FUNCTION hi_PutRegAdd                LIB "HIME.dll"( lAddress AS LONG     , LLen AS LONG         ,      lReg AS LONG       )    AS                   LONG                                                               
    DECLARE FUNCTION hi_PutRegAsciiz             LIB "HIME.dll"( azData AS ASCIIZ     , lReg AS LONG         ) AS LONG
    DECLARE FUNCTION hi_PutRegDword              LIB "HIME.dll"(dData AS DWORD, lReg AS LONG) AS LONG
    DECLARE FUNCTION hi_PutRegFromClipboard      LIB "HIME.dll"( lReg AS LONG) AS LONG
    DECLARE FUNCTION hi_PutRegFromFile           LIB "HIME.dll"( lReg_FileName AS LONG, lReg AS LONG) AS LONG
    DECLARE FUNCTION hi_PutRegLong               LIB "HIME.dll"(lData AS LONG, lReg AS LONG) AS LONG
    DECLARE FUNCTION hi_ReadPrimes               LIB "HIME.dll"( lPrimesToRead AS LONG) AS LONG                                                                                                                    
    DECLARE FUNCTION hi_Rec_AddField             LIB "HIME.dll"( Fld AS LONG          , Rec AS LONG) AS LONG
    DECLARE FUNCTION hi_Rec_GetField             LIB "HIME.dll"( Rec AS LONG          , Index AS LONG        , Fld AS LONG) AS LONG
    DECLARE FUNCTION hi_Rec_GetNrFields          LIB "HIME.dll"( Rec AS LONG) AS LONG
    DECLARE FUNCTION hi_RegAllocate              LIB "HIME.dll"() AS LONG
    DECLARE FUNCTION hi_RegAllocateMultiple      LIB "HIME.dll"( lRegs AS LONG) AS LONG
    DECLARE FUNCTION hi_RegAllocateRange         LIB "HIME.dll"( lFirstReg AS LONG, lLastReg AS LONG) AS LONG
    DECLARE FUNCTION hi_RegChangeEndian          LIB "HIME.dll"( lReg1 AS LONG        , lReg_Result AS LONG) AS LONG
    DECLARE FUNCTION hi_RegClear                 LIB "HIME.dll"( lReg AS LONG) AS LONG
    DECLARE FUNCTION hi_RegCompare               LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG) AS LONG
    DECLARE FUNCTION hi_RegConcatByte            LIB "HIME.dll"( lReg AS LONG         , lVal AS LONG         ) AS LONG
    DECLARE FUNCTION hi_RegConcatReg             LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        , lReg3 AS LONG) AS LONG
    DECLARE FUNCTION hi_RegGetLen                LIB "HIME.dll"( lReg AS LONG         ) AS LONG
    DECLARE FUNCTION hi_Register                 LIB "HIME.dll"( lReg1 AS LONG        ) AS                    LONG                                                                                                                    
    DECLARE FUNCTION hi_RegMaxAllocated          LIB "HIME.dll"() AS LONG
    DECLARE FUNCTION hi_RegReverse               LIB "HIME.dll"( lReg1 AS LONG        , lReg_Result AS LONG) AS LONG
    DECLARE FUNCTION hi_RegSplit                 LIB "HIME.dll"( lRegIn AS LONG       , lBytes AS LONG       , lRegL AS LONG, lRegR AS LONG) AS LONG
    DECLARE FUNCTION hi_RegUnAllocate            LIB "HIME.dll"( lReg AS LONG) AS LONG
    DECLARE FUNCTION hi_RegUnAllocateRange       LIB "HIME.dll"( lFirstReg AS LONG    , lLastReg AS LONG) AS LONG
    DECLARE FUNCTION hi_RegWipe                  LIB "HIME.dll"( lReg AS LONG         , Mode AS LONG         , Clr AS LONG) AS LONG
    DECLARE FUNCTION hi_Root_N                   LIB "HIME.dll"(lReg1 AS LONG, lN AS LONG, lCalcRem AS LONG, lReg_Root AS LONG, lReg_Rem AS LONG) AS LONG
    DECLARE FUNCTION hi_Root_Sqrt                LIB "HIME.dll"(lReg1 AS LONG, lCalcRem AS LONG, lReg_Root AS LONG, lReg_Rem AS LONG) AS LONG
    DECLARE FUNCTION hi_RSA_Pad_PKCS1_1_5        LIB "HIME.dll"(lReg_Plaintext AS LONG, lReg_Modul AS LONG, lReg_Result AS LONG) AS LONG
    DECLARE FUNCTION hi_RSA_Unpad_PKCS1_1_5      LIB "HIME.dll"(lReg_PaddedPlaintext AS LONG, lReg_Plaintext AS LONG) AS LONG
    DECLARE FUNCTION hi_SetOption                LIB "HIME.dll"( lOption AS LONG      , lParam AS LONG) AS LONG
    DECLARE FUNCTION hi_ShredDisk                LIB "HIME.dll"(lReg_DiskName AS LONG, Passes AS LONG, Algo AS LONG, Parameter AS LONG, lReg_Command AS LONG, lReg_Status AS LONG) AS LONG
    DECLARE FUNCTION hi_ShredFile                LIB "HIME.dll"( lReg_FileName AS LONG, Filemode AS LONG     , Passes AS LONG, Algo AS LONG, Parameter AS LONG, lReg_Command AS LONG, lReg_Status AS LONG) AS LONG
    DECLARE FUNCTION hi_Square                   LIB "HIME.dll"( lReg1 AS LONG        , lReg_Result AS LONG  )      AS                  LONG
    DECLARE FUNCTION hi_StackWipe                LIB "HIME.dll"( StackSize AS LONG    , Clearance AS LONG) AS LONG
    DECLARE FUNCTION hi_Sub                      LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        ,      lReg_Result AS LONG)    AS                   LONG                                                               
    DECLARE FUNCTION hi_SwapReg                  LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        )      AS                  LONG                                                                                         
    DECLARE FUNCTION hi_TrimLZeroes              LIB "HIME.dll"( lRegIn AS LONG       , lRegOut AS LONG      ) AS LONG
    DECLARE FUNCTION hi_Version                  LIB "HIME.dll" AS LONG                                                                                                                                                                  
    DECLARE FUNCTION hi_Xor                      LIB "HIME.dll"( lReg1 AS LONG        , lReg2 AS LONG        , lReg_Result AS LONG) AS LONG
    
    '--------------------------------------------------------------------
    Last edited by Eddy Van Esch; 17 Jan 2008, 10:38 AM.
    Eddy

    Comment


    • #3
      This is PBFORMS.inc
      I assume I am allowed to post this ?

      Code:
      '---------------------------------------------------------------------------------
      '
      '   ** PBForms.inc ** Macros for PowerBASIC Forms
      '
      '   Copyright (c) 2002, 2003 PowerBASIC, Inc.
      '   All Rights Reserved.
      '
      '   Last Update: 09 May 2003
      '
      '   Note: PowerBASIC Forms expects the macros to be in the original form.
      '         Any modification to the macros could cause the generated PBForms
      '         files to not compile or function as expected.
      '
      '---------------------------------------------------------------------------------
      
      #IF NOT %DEF(%PBFORMS_INC)
      
      '---------------------------------------------------------------------------------
      '   ** Constants **
      '---------------------------------------------------------------------------------
      %PBFORMS_INC = 1
      
      '---------------------------------------------------------------------------------
      '   ** Structures **
      '---------------------------------------------------------------------------------
      #IF NOT %DEF(%COMMCTRL_INC)
      TYPE INIT_COMMON_CONTROLSEX
          dwSize AS DWORD   ' size of this structure
          dwICC  AS DWORD   ' flags indicating which classes to be initialized
      END TYPE
      #ENDIF
      
      '---------------------------------------------------------------------------------
      '   ** Declarations **
      '---------------------------------------------------------------------------------
      DECLARE FUNCTION PBFormsInitCommonControlsEx(iccex AS INIT_COMMON_CONTROLSEX) AS LONG
      
      '---------------------------------------------------------------------------------
      '   ** Macros **
      '---------------------------------------------------------------------------------
      MACRO FUNCTION PBFormsMakeFont(sFntName, fFntSize, lWeight, lUnderlined, lItalic, lStrike, lCharSet)
      '
      ' Examples of Use:
      '
      '    hFont = PBFormsMakeFont("MS Sans Serif", 8, %FW_NORMAL, %FALSE, %FALSE, %FALSE, %DEFAULT_CHARSET)
      '    hFont = PBFormsMakeFont("Courier New", 10, %FW_BOLD, %FALSE, %FALSE, %FALSE, %DEFAULT_CHARSET)
      '    hFont = PBFormsMakeFont("Marlett", 8, %FW_NORMAL, %FALSE, %FALSE, %FALSE, %SYMBOL_CHARSET)
      '
      ' Note: Any font created with PBFormsMakeFont should also be destroyed with DeleteObject
      '       when no longer needed to prevent memory leaks.  For example:
      '
      '        Case %WM_DESTROY
      '            DeleteObject hFont
      
          MACROTEMP       lf
          MACROTEMP       hDC
          MACROTEMP       lCyPixels
      
          DIM lf          AS LOGFONT
          DIM hDC         AS DWORD
          DIM lCyPixels   AS LONG
      
          hDC         = GetDC(%HWND_DESKTOP)
          lCyPixels   = GetDeviceCaps(hDC, %LOGPIXELSY)
          ReleaseDC %HWND_DESKTOP, hDC
      
          lf.lfHeight         = -(fFntSize * lCyPixels) \ 72
          lf.lfFaceName       = sFntName
          lf.lfPitchAndFamily = %FF_DONTCARE
          IF lWeight = %FW_DONTCARE THEN
              lf.lfWeight = %FW_NORMAL
          ELSE
              lf.lfWeight = lWeight
          END IF
          lf.lfUnderline  = lUnderlined
          lf.lfItalic     = lItalic
          lf.lfStrikeOut  = lStrike
          lf.lfCharSet    = lCharSet
      
      END MACRO = CreateFontIndirect(lf)
      '---------------------------------------------------------------------------------
      
      '---------------------------------------------------------------------------------
      MACRO PBFormsInitComCtls(icc)
          MACROTEMP   iccex
          MACROTEMP   hLib
          MACROTEMP   pProc
      
          DIM iccex   AS INIT_COMMON_CONTROLSEX
          DIM hLib    AS DWORD
          DIM pProc   AS DWORD
      
          hLib = LoadLibrary("COMCTL32.DLL")
          IF hLib THEN
              pProc = GetProcAddress(hLib, "InitCommonControlsEx")
              IF pProc THEN
                  iccex.dwSize    = SIZEOF(iccex)
                  iccex.dwICC     = icc
                  CALL DWORD pProc USING PBFormsInitCommonControlsEx(iccex)
              ELSE
                  InitCommonControls
              END IF
              FreeLibrary hLib
          END IF
      END MACRO
      '---------------------------------------------------------------------------------
      
      '---------------------------------------------------------------------------------
      '   ** Functions **
      '---------------------------------------------------------------------------------
      #IF %DEF(%RICHEDIT_INC) ' Include only if RICHEDIT.INC is included in the code
      
      FUNCTION PBFormsRichEdit(OPTIONAL BYVAL fUnLoad AS LONG) AS STRING
          ' * PBFormsRichEdit() without a parameter will load and return the
          '   class name of the best possible version of RichEdit installed.
          ' * Subsequent calls simply return the class name (eg, for use in
          '   CONTROL ADD statements, etc).
          ' * PBFormsRichEdit(%TRUE) will force the library to be unloaded.
      
          STATIC hLibRichEdit    AS DWORD
          STATIC szRichEditClass AS STRING
      
          IF ISFALSE fUnload THEN
              ' Load and/or return class name
              IF ISFALSE hLibRichEdit THEN
                  ' First try RichEdit 4.1 (Windows XP/SP1)
                  hLibRichEdit = LoadLibrary("MSFTEDIT.DLL")
      
                  IF ISTRUE hLibRichEdit THEN
                      szRichEditClass = "RichEdit50W"
      
                  ELSE
                      ' Next try RichEdit 2.0 or 3.0
                      hLibRichEdit = LoadLibrary("RICHED20.DLL")
      
                      IF ISTRUE hLibRichEdit THEN
                          szRichEditClass = "RichEdit20A"
      
                      ELSE
                          ' Else try RichEdit 1.0
                          hLibRichEdit = LoadLibrary("RICHED32.DLL")
      
                          IF ISTRUE hLibRichEdit THEN
                              szRichEditClass = "RichEdit"
      
                          ELSE
                              ' No RichEdit control available, use Edit.
                              szRichEditClass = "Edit"
                          END IF
                      END IF
                  END IF
              END IF
              ' Return the class name
              FUNCTION = szRichEditClass
          ELSE
              ' Unload the RichEdit library
              IF hLibRichEdit THEN
                  CALL FreeLibrary(hLibRichEdit)
                  hLibRichEdit = 0
              END IF
              FUNCTION = ""
          END IF
      END FUNCTION
      
      '---------------------------------------------------------------------------------
      #ENDIF ' #IF %DEF(%RICHEDIT_INC)
      
      '---------------------------------------------------------------------------------
      #ENDIF ' #IF NOT %DEF(%PBFORMS_INC)
      Eddy

      Comment


      • #4
        Related thread here .

        Kind regards
        Eddy

        Comment

        Working...
        X