The work is done. The code is as follows:
===============iss code================
function IsDefineSpoSame(file1: string; file2: string): Boolean;
external 'IsDefineSpoSame@files:pbdata.dll stdcall setuponly';
....
Profession := False;
if FileExists(WizardDirValue() + ExpandConstant('\{#MyInstallFlagFile}')) then begin
ExtractTemporaryFile('{#MyProfessionFlagFile}');
if FileExists(ExpandConstant('{tmp}\{#MyProfessionFlagFile}')) then
begin
Profession := IsDefineSpoSame(WizardDirValue() + ExpandConstant('\{#MyInstallFlagFile}'), ExpandConstant('{tmp}\{#MyProfessionFlagFile}'));
DeleteFile(ExpandConstant('{tmp}\{#MyProfessionFlagFile}'));
end
end;
===============c code================
#define BUFFERSIZE_DEFINE_SPO 30
extern "C" BOOL APIENTRY IsDefineSpoSame(const wchar_t* file1, const wchar_t* file2)
{
BOOL result = FALSE;
FILE *stream1, *stream2;
unsigned char buff1[BUFFERSIZE_DEFINE_SPO + 1], buff2[BUFFERSIZE_DEFINE_SPO + 1], *p;
size_t numread1, numread2, compareCount, offset;
if ((stream1 = _wfsopen(file1, L"rb", _SH_DENYWR)) != NULL) {
if ((stream2 = _wfsopen(file2, L"rb", _SH_DENYWR)) != NULL)
{
numread1 = fread_s(buff1, BUFFERSIZE_DEFINE_SPO, 1, BUFFERSIZE_DEFINE_SPO, stream1);
compareCount = numread2 = fread_s(buff2, BUFFERSIZE_DEFINE_SPO, 1, BUFFERSIZE_DEFINE_SPO, stream2);
// do real work
if (numread1 != numread2) {
if (numread1 < numread2) {
p = buff2 + numread1;
compareCount = numread1;
offset = numread2 - numread1;
}
else {
p = buff1 + numread2;
compareCount = numread2;
offset = numread1 - numread2;
}
for (size_t i = 0; i < offset; ++i) {
if (p[i] != '\xd' && p[i] != '\xa') {
goto IsDefineSpoSameOut1;
}
}
}
result = 0 == memcmp(buff1, buff2, compareCount);
IsDefineSpoSameOut1:
fclose(stream2);
}
fclose(stream1);
}
return result;
}