Visual Studio C++ Language LoadLibrary Sample Snippet

While specific instructions are given here for Visual Studio, the wh32.dll should be useable by any C++ compiler. 

There are 2 ways you can use our library in a c++ program.  One of them is the LoadLibrary method (Dynamic Loading) which is what will be illustrated here. 



We include a sample application written in Visual Studio 2019 C++ which uses dynamic linking. It is for 64 bit and includes version 2020.06 of the Withholding32 library. To get it Click Here

Both the 32 bit and 64 bit libraries are included so it could be configured to do a 32 bit build also (remember to find and change wh32_64.dll to wh32.dll).

Structures

All structures you will need are defined in our online manual or in the  header file wh32.h supplied with the library.


Loading the Library

You must declare the Withholding32 functions you will use. The first time you actually call one of these functions it will be loaded into memory by the operating system. Here is an example.  Note that, as shown, the actual wh32.dll should be in the same folder as the executable.
 
INSTANCE hGetProcIDDLL = LoadLibrary(TEXT("wh32.dll"));
DWORD dw=GetLastError();

Sample Execution Code

Here is a code snippet which shows how you would actually use one of the Withholding32 functions. This particular snippet sets up an array of county names and calculation codes for Marylang. Note that it is required that any structure with a 'struct-size' member be filled in correctly before calling the function.


FARPROC lpfnGetProcessID3 = GetProcAddress(HMODULE (hGetProcIDDLL),"WH32_Get_Prompt");
typedef long(__stdcall * pICFUNC3)(WITHHOLDING_TAXBODY_INFO *wt,char * c);
pICFUNC3 WH32_Get_Prompt;
WH32_Get_Prompt=pICFUNC3(lpfnGetProcessID3);
dw=GetLastError();

/*
Next have function return total number of possible local
taxing names in parameter number_of_entries;
*/
wt.desired_entry=0;
wt.muni_number=0;
wt.state=WH32_COLORADO;
ll=WH32_Get_Prompt(&wt,&thename[0]);
max_entries=wt.number_of_entries;

/*
Now get all Colorado local prompts
*/
for(i=0;i<max_entries;i++){
  wt.desired_entry=i;
  ll=WH32_Get_Prompt(&wt,&thename[0]);
  m_IDC_local_tax.AddString(&thename[0]);
  m_local_tax_ids[i]=wt.calc_number;
}