Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project1;
- {$APPTYPE CONSOLE}
- uses
- Windows, SysUtils;
- type
- PZIP = ^TZIP;
- TZIP = array[0..4] of AnsiChar;
- PState = ^TState;
- TState = array[0..1] of AnsiChar;
- PCityName = ^TCityName;
- TCityName = array[0..27] of AnsiChar;
- PCountyNum = ^TCountyNum;
- TCountyNum = array[0..2] of AnsiChar;
- PCountyName = ^TCountyName;
- TCountyName = array[0..24] of AnsiChar;
- // typedef int (CALLBACK* FindCityCounty)(
- // char ZIP[5],char cityname[28],char state[2],char countyname[25],char countynum[3]);
- TFindCityCounty = function(ZIP: PZIP; CityName: PCityName; State: PState; CountyName: PCountyName;
- CountyNum: PCountyNum): Integer; stdcall;
- procedure runCA(pCA: TFindCityCounty);
- var
- rc: Integer;
- ZIP: TZIP;
- State: TState;
- CityName: TCityName;
- CountyNum: TCountyNum;
- CountyName: TCountyName;
- begin
- // set input parameters - strncpy(ZIP,"10601",5);
- Move(AnsiString('10601'), ZIP[0], 5 * SizeOf(AnsiChar));
- // print the input
- Writeln('Input ZIP code: ', ZIP);
- // call the function - no result checking in the original example code ? [DCC Hint] H2077
- rc := pCA(@ZIP, @CityName, @State, @CountyName, @CountyNum);
- // print the output
- Writeln('Output city: ', CityName);
- Writeln('Output state: ', State);
- Writeln('Output county name: ', CountyName);
- Writeln('Output county number: ', CountyNum);
- end;
- var
- hDLL: HMODULE;
- pCA: TFindCityCounty;
- begin
- // Load DLL and get function location
- hDLL := LoadLibrary('CorrectA.dll');
- if hDLL <> 0 then
- try
- pCA := GetProcAddress(hDLL, 'FindCityCounty');
- if Assigned(pCA) then
- runCA(pCA)
- else
- Writeln('FindCityCounty function could not be found.');
- finally
- FreeLibrary(hDLL);
- end;
- Readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement