Call procedure from user library (DLL)

Keyword

<#CallLib0> - <#CallLib9>

Parameters

Calling procedure name [optional parameters string for procedure].

Action

Calls user defined procedure from user-defined Dynamic Link Library (DLL).

Remarks

Library index 0 can be omitted. Procedure name and parameters string must be separated by the space symbol. User defined procedure has access to internal PenCommand variables and can change them.

 

Defining a function in user DLL (C/C++ code):

 

typedef TCHAR MCR_STRINGS_TYPE[10][256];

typedef TCHAR MCR_SYMBS_TYPE[10];

typedef INT   MCR_INTS_TYPE[10];

 

typedef _declspec(dllexport) BOOL UserProcName(

MCR_STRINGS_TYPE *pStrings,

MCR_SYMBS_TYPE *pSymbs,

MCR_INTS_TYPE *pInts,

TCHAR *pParmStr,

LPARAM lParam

);

 

 

Example of a user-defined procedure

 

The code below is taken from macrusr.dll included with Visual PenCommander, CalliGrapher and PenOffice. You may obtain the  complete code of this DLL from PhatWare Cop. For more information, please visit PhatWare developer's web site at http://www.calligrapher.net.

 

// PenCommand for typing the current Time

// Load User Library

<#LoadLib>D:\Cgr98\macrousr.dll     

// Call user defined function UsrPutTimeToStr, which puts current time in American style to String5 variable

<#CallLib>UsrPutTimeToStr 5 0

// Free User Library

<#FreeLib>

// type String5 content

<#Type> <*str5>

 

User-defined function in C/C++:

 

_declspec(dllexport) BOOL UsrPutTimeToStr(

MCR_STRINGS_TYPE *pStrings,

MCR_SYMBS_TYPE *pSymbs,

MCR_INTS_TYPE *pInts,

TCHAR *pParmStr,

LPARAM lParam)

{

   int    iStrNum = 0;  // target string number

   int    iFormat = 0;  // time format (0-American; non-0 - European)

   SYSTEMTIME st;       // struct for GetLocalTime()

 

   //read target string number and time format type

 

   if(pParmStr==0 ||

      _stscanf(pParmStr, TEXT("%d %d"), &iStrNum, &iFormat)<1 ||

      iStrNum<0 || iStrNum>9)

   {

      return FALSE;

   }

   GetLocalTime(&st);

   

   if ( iFormat == 0 )

   {

        // AM/PM time format

        TCHAR AmPm;

        int   iHour;

 

        if(st.wHour>=12)

            AmPm = 'P';

        else

            AmPm = 'A';

        if ( (iHour=st.wHour%12) == 0 )

            iHour = 12;

        wsprintf((*pStrings)[iStrNum], "%d:%02d %cM.", iHour, (int)st.wMinute, AmPm);

   }

   else

   {

        // 24 - hours time format

        wsprintf((*pStrings)[iStrNum], "%d:%02d", (int)st.wHour, (int)st.wMinute);

   }

   return TRUE;

}

 

See Also

Load user library (DLL)

Free user library (DLL)

Variables