#ifndef DUJUNLITOOLSCPP
#define DUJUNLITOOLSCPP
//函数库2002-11-15 19:26
#include <vcl.h>
#include <grids.hpp>
#include <stdio.h>
#include <utilcls.h>
#include <printers.hpp>
#include <IdBaseComponent.hpp>
#include <IdCoder.hpp>
#include <IdCoderMessageDigest.hpp>
///md5
AnsiString __fastcall Strip(AnsiString S)
{
return S.Delete(1, 2);
}
AnsiString md5ToString(AnsiString S)
{
AnsiString AHex;
for (int i=1; i<=S.Length(); i++)
{
AHex += IntToHex((unsigned char)S[i], 2);// + " ";
}
return AHex;
}
String Md5Str(String src)
{
TIdCoderMD5 *md5=new TIdCoderMD5(NULL);
md5->Reset();
md5->AutoCompleteInput = true;
String tmp=md5ToString(Strip(md5->CodeString(src)));
delete md5;
md5=NULL;
return tmp;
}
//md5 end
bool OpenForm(TForm * WForm)
{
//if(OpenForm(frmmem)==False)
// {
// frmmem=new Tfrmmem(Application);
// OpenForm(frmmem);
// }//使用例子
int i;
bool FormExist;
if(WForm==NULL) return False;
FormExist=False;
for(i=0;i<Screen->FormCount;i++)
if(Screen->Forms[i]->ClassType()==WForm->ClassType())
{
FormExist=True;
break;
}
if(FormExist==False) return FormExist;
if(WForm->WindowState==wsMinimized)
ShowWindow(WForm->Handle,SW_SHOWNORMAL);
else
ShowWindow(WForm->Handle,SW_SHOWNA);
if(!WForm->Visible) WForm->Visible=True;
if(GetWindowLong(WForm->Handle,GWL_EXSTYLE&WS_EX_APPWINDOW)!=WS_EX_APPWINDOW)
SetWindowLong(WForm->Handle,GWL_EXSTYLE,WS_EX_APPWINDOW);
WForm->BringToFront();
WForm->SetFocus();
return True;
}
//----------------------------------------------------------------
String repl(String sstr,String fstr,String repstr)
{
//替换字符串函数
String tmpstr="";
int x = sstr.AnsiPos(fstr);
if(x==0)
{
tmpstr=sstr;
//Application->MessageBoxA(sstr.c_str(),"",MB_OK); //未找到查找字串,原样返回
return tmpstr;
}
while(x != 0)
{
tmpstr +=sstr.SubString(1,x-1) + repstr;
sstr = sstr.SubString(x+fstr.Length(),sstr.Length());
x = sstr.AnsiPos(fstr);
}
tmpstr+=sstr;
//Application->MessageBoxA(tmpstr.c_str(),"",MB_OK);
return tmpstr;
}
//---------------------------------------------
String sqlstr(String sqlstr)
{
//
if(sqlstr!="")
{
sqlstr=repl(sqlstr,"'","''");
}
return sqlstr;
}
//---------------------------------