Subject Re: [ib-support] Re: UDF
Author Robert F. Tulloch
Hi:

C++

Clears the IBLog and deletes back ups.



.bpf

USEUNIT("ltudf.cpp");
USERES("ltUDF.res");
//---------------------------------------------------------------------------
This file is used by the project manager only and should be treated
like the project file


DllEntryPoint


--------------------------------------------------------------------------------

.h

#include <stdio.h>

extern "C" __declspec(dllexport) char* __stdcall fn_ClearIbLog(String
FilePath);

extern "C" __declspec(dllexport) char* __stdcall
fn_DeleteIbBackup(String FilePath);



.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#include <windows.h>
#include <string.h>
#pragma hdrstop
#include "ltudf.h"
//---------------------------------------------------------------------------
char *buf;
char* __stdcall fn_ClearIbLog(String FilePath)
{
char *s;
TStringList *IBLog = new TStringList();
try
{
IBLog->LoadFromFile(FilePath);
IBLog->Clear();
IBLog->Add(" ");
String NewHeader = "LTDMS Interbase.Log cleared on " +
DateToStr(Date());
IBLog->Add(NewHeader);

IBLog->Add("------------------------------------------------------------");
IBLog->SaveToFile(FilePath);
delete IBLog;
s = "True";
}
catch(...)
{
delete IBLog;
s = "False";
}
char *p;
buf = (char*)malloc(strlen (s) + 1);
p = buf;
while (*s)
*p++ = *s++;
*p = '\0';

return buf;
}

char* __stdcall fn_DeleteIbBackup(String FilePath)
{
char *s;
try
{
if (FileExists(FilePath))
{
DeleteFile(FilePath);
s = "True";
}
else
s = "False";
}
catch(...)
{
s = "False";
}
char *p;
buf = (char*)malloc(strlen (s) + 1);
p = buf;
while (*s)
*p++ = *s++;
*p = '\0';

return buf;
}






//---------------------------------------------------------------------------

#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*
lpReserved)
{
return 1;
}