CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Delphi >  语言基础/算法/系统设计

C++ Builder 转 Delphi

楼主bbm011(只爱花香)2005-11-18 13:48:37 在 Delphi / 语言基础/算法/系统设计 提问

//      
   
  //   DllCall.cpp   :   implementation   file  
  #include   <vcl.h>  
  #include   "DllCall.h"  
  /////////////////////////////////////////////////////////////////////////////  
  __fastcall   TDllCall::TDllCall()  
  {  
  nTagAdr   =   0;  
  bConnect   =   FALSE;  
  bDisConnect   =   TRUE;  
  }  
   
  /////////////////////////////////////////////////////////////////////////////  
  __fastcall   TDllCall::~TDllCall()  
  {  
  }  
   
  /////////////////////////////////////////////////////////////////////////////  
  BOOL   __fastcall   TDllCall::LoadFunction()  
  {  
  lpOpenDevice   =   (OPENDEVICE*)::GetProcAddress(hLibrary,   "OpenDevice");  
  if(lpOpenDevice   ==   NULL)  
  {  
                  FreeLibrary(hLibrary);  
  return   FALSE;  
  }  
   
  lpRecvEdition   =   (RECVEDITION*)::GetProcAddress(hLibrary,   "RecvEdition");  
  if(lpRecvEdition   ==   NULL)  
  return   FALSE;  
   
  lpSetMyAddress   =   (SETMYADDRESS*)::GetProcAddress(hLibrary,   "SetMyAddress");  
  if(lpSetMyAddress   ==   NULL)  
  return   FALSE;  
   
  lpConnect   =   (CONNECT*)::GetProcAddress(hLibrary,   "ConnectPort");  
  if(lpConnect   ==   NULL)  
  return   FALSE;  
   
  lpSetAddLog   =   (SETADDLOG*)::GetProcAddress(hLibrary,   "SetAddLog");  
  if(lpSetAddLog   ==   NULL)  
  return   FALSE;  
   
  lpSetInnerCode   =   (SETINNERCODE*)::GetProcAddress(hLibrary,   "SetInnerCode");  
  if(lpSetInnerCode   ==   NULL)  
  return   FALSE;  
   
  lpSetInnerCmd   =   (SETINNERCMD*)::GetProcAddress(hLibrary,   "SetInnerCmd");  
  if(lpSetInnerCmd   ==   NULL)  
  return   FALSE;  
   
  lpSetWaitTime   =   (SETWAITTIME*)::GetProcAddress(hLibrary,   "SetWaitTime");  
  if(lpSetWaitTime   ==   NULL)  
  return   FALSE;  
   
  lpSetCommKey   =   (SETCOMMKEY*)::GetProcAddress(hLibrary,   "SetCommKey");  
  if(lpSetCommKey   ==   NULL)  
  return   FALSE;  
   
  lpStartICDMCmd   =   (STARTICDMCMD*)::GetProcAddress(hLibrary,   "StartICDMCommand");  
  if(lpStartICDMCmd   ==   NULL)  
  return   FALSE;  
   
  lpGetSizeOfData   =   (GETSIZEOFDATA*)::GetProcAddress(hLibrary,   "GetSizeOfData");  
  if(lpGetSizeOfData   ==   NULL)  
  return   FALSE;  
   
  lpGetData   =   (GETDATA*)::GetProcAddress(hLibrary,   "GetData");  
  if(lpGetData   ==   NULL)  
  return   FALSE;  
   
  lpGetCmdResult   =   (GETCMDRESULT*)::GetProcAddress(hLibrary,   "GetCmdResult");  
  if(lpGetCmdResult   ==   NULL)  
  return   FALSE;  
   
  lpEndICDMCmd   =   (ENDICDMCMD*)::GetProcAddress(hLibrary,   "EndICDMCommand");  
  if(lpEndICDMCmd   ==   NULL)  
  return   FALSE;  
   
  lpDisConnect   =   (DISCONNECT*)::GetProcAddress(hLibrary,   "DisConnectPort");  
  if(lpDisConnect   ==   NULL)  
  return   FALSE;  
   
  lpCloseDevice   =   (CLOSEDEVICE*)::GetProcAddress(hLibrary,   "CloseDevice");  
  if(lpCloseDevice   ==   NULL)  
  return   FALSE;  
   
                   
  lpSendFrame   =   (SENDFRAME*)::GetProcAddress(hLibrary,   "SendFrame");  
  if(lpSendFrame   ==   NULL)  
  return   FALSE;  
   
  lpClearRecvStr   =   (CLEARRECVSTR*)::GetProcAddress(hLibrary,   "ClearRecvStr");  
  if(lpClearRecvStr   ==   NULL)  
  return   FALSE;  
   
  lpRecvStream   =   (RECVSTREAM*)::GetProcAddress(hLibrary,   "RecvStream");  
  if(lpRecvStream   ==   NULL)  
  return   FALSE;  
   
  lpRecvHDLC   =   (RECVHDLC*)::GetProcAddress(hLibrary,   "RecvHDLC");  
  if(lpRecvHDLC   ==   NULL)  
  return   FALSE;  
   
   
   
  return   TRUE;  
  }  
   
  /////////////////////////////////////////////////////////////////////////////  
  String   __fastcall   TDllCall::ShowMessage(int   nMessage,   int   nFontMsg)  
  {  
  String   strResult;  
  INFOCODE   nInfoCode   =   (INFOCODE)nMessage;  
          FONT   nFont   =   (FONT)nFontMsg;  
  switch(nFont)  
  {  
                  case   nUSEnglish:  
                          if(nInfoCode   ==   nSendSuccess   ||   nInfoCode   ==   nSuccess   ||  
                                nInfoCode   ==   nRecvSuccess   ||   nInfoCode   ==   nRecvEmpty)  
                                  strResult   =   "Success";  
                          else  
                                  strResult   =   "Failure";  
                  break;  
                  case   nPRCChinese:  
                          if(nInfoCode   ==   nSendSuccess   ||   nInfoCode   ==   nSuccess   ||  
                                nInfoCode   ==   nRecvSuccess   ||   nInfoCode   ==   nRecvEmpty)  
                                  strResult   =   "成功";  
                          else  
                                  strResult   =   "失败";  
                  break;  
                  case   nTaiWanChinese:  
                          if(nInfoCode   ==   nSendSuccess   ||   nInfoCode   ==   nSuccess   ||  
                                nInfoCode   ==   nRecvSuccess   ||   nInfoCode   ==   nRecvEmpty)  
                                  strResult   =   "Θ";  
                          else  
                                  strResult   =   "ア毖";  
                  break;  
          }  
   
  return   strResult;  
  }  
   
  String   __fastcall   TDllCall::AddZero(String   strData,   int   nLength)  
  {  
          while(strData.Length()   <   nLength)  
                  strData   =   "0"   +   strData;  
          return   strData;  
  } 问题点数:50、回复次数:4Top

1 楼bbm011(只爱花香)回复于 2005-11-18 13:48:56 得分 0

/////////////////////////////////////////////////////////////////////////////  
  int   __fastcall   TDllCall::myatoi(char   chChar)  
  {  
  if   (chChar   >=   '0'   &&   chChar   <=   '9')  
  return   chChar   -   '0';  
  else   if   (chChar   >=   'a'   &&   chChar   <=   'f')  
  return   chChar   -   'a'   +   10;  
  else   if   (chChar   >=   'A'   &&   chChar   <=   'F')  
  return   chChar   -   'A'   +   10;  
  else   if   (chChar   ==   '   ')  
                                  return   -1;  
                  else  
  return   -2;  
  }  
   
   
  String   __fastcall   TDllCall::HexToStr(int   n)  
  {  
  String   str;  
          char   ch[10];  
  wsprintf(ch,   "%02x",   (BYTE)n);  
          str   =   ch;  
          return   str;  
  }  
   
   
  String   __fastcall   TDllCall::Learch(const   String&   strSrc,   char   chChar)  
  {  
  String   strDest;  
  for(int   iLoop   =   1;   iLoop   <=   strSrc.Length();   iLoop   ++)  
  if   (strSrc[iLoop]   !=   chChar)  
  strDest   +=   (char)strSrc[iLoop];  
  return   strDest;  
  }  
   
  void   __fastcall   TDllCall::WriteFile(int   nAdr,   int   nInfoReturn,   int   nHandle,   String   strSectorNum,  
                                                                          String   strOldAKey,   String   strOldBKey,   String   strNewAKey,   String   strNewBKey)  
  {  
  SYSTEMTIME   LocalTime;  
  GetLocalTime(&LocalTime);  
          String   strAdr   =   "Address:"   +   AddZero(IntToStr(nAdr),   3)   +   ",";  
          String   strHandle   =   "Handle:"   +   AddZero(IntToStr(nHandle),   3)   +   ",";  
          String   strSector   =   "Sector:"   +   strSectorNum   +   ",";  
          String   strKey   =   "Old   A_Key:"   +   strOldAKey   +   ",Old   B_Key:"   +   strOldBKey   +  
                                                  "\r\n"   +   "New   A_Key:"   +   strNewAKey   +   ",New   B_Key:"   +   strNewBKey;  
          String   strRlt;  
          if(nInfoReturn   ==   nSuccess)  
                  strRlt   =   "Result:Success,";  
          else  
                  strRlt   =   "Result:     Fail   ,";  
          String   strDate   =   AddZero(IntToStr(LocalTime.wYear),   4)   +   "-"   +  
                                                    AddZero(IntToStr(LocalTime.wMonth),   2)   +   "-"   +  
                                                    AddZero(IntToStr(LocalTime.wDay),   2)   +   ",";  
          String   strTime   =   AddZero(IntToStr(LocalTime.wHour),   2)   +   ":"   +  
                                                    AddZero(IntToStr(LocalTime.wMinute),   2)   +   ":"   +  
                                                    AddZero(IntToStr(LocalTime.wSecond),   2);  
          String   StrRecord   =   strAdr   +   strHandle   +   strSector   +   strRlt   +   strDate   +   strTime  
                                                        +   "\r\n"   +   strKey   +   "\r\n\r\n";  
          FileSeek(nFileHandle,   0,   2);  
          FileWrite(nFileHandle,   StrRecord.c_str(),   StrRecord.Length());  
  }  
   
  String   __fastcall   TDllCall::AddAttGuardRecord(int   nCount,   ATTGUARDRECORD   CardRecord)  
  {  
          String   strCount   =   AddZero(IntToStr(nCount),   5);  
          String   strPersonID,   strFlowID1,   strFlowID2;  
          for   (int   nLoop   =   0;   nLoop   <   7;   nLoop   ++)  
                  strPersonID   +=   CardRecord.tPersonID.str[nLoop];  
          String   strYear   =   AddZero(IntToStr(CardRecord.nYear),   4);  
          String   strMonth   =   AddZero(IntToStr(CardRecord.nMonth),   2);  
          String   strDay   =   AddZero(IntToStr(CardRecord.nDay),   2);  
          String   strHour   =   AddZero(IntToStr(CardRecord.nHour),   2);  
          String   strMinute   =   AddZero(IntToStr(CardRecord.nMinute),   2);  
          String   strSecond   =   AddZero(IntToStr(CardRecord.nSecond),   2);  
          String   strAdr   =   AddZero(IntToStr(CardRecord.nAdr),   3);  
          String   strIsOnDuty,   strIsBC,   str;  
          if(CardRecord.bOnDuty)  
                  strIsOnDuty   =   "1";  
          else  
                  strIsOnDuty   =   "0";  
          if(CardRecord.bBC)  
                  strIsBC   =   "1";  
          else  
                  strIsBC   =   "0";  
          strFlowID1   =   strYear.SubString(3,   2)   +   strMonth   +   strDay;  
          strFlowID2   =   strAdr   +   strCount;  
          str   =   strFlowID1   +   strFlowID2   +   ","   +   strPersonID   +   ","   +   strYear   +   "-"   +   strMonth   +   "-"   +  
                      strDay   +   ","   +   strHour   +   ":"   +   strMinute   +   ":"   +   strSecond   +   ","   +  
                      strIsOnDuty   +   ","   +   strIsBC   +   "\r\n";  
          return   str;  
  }  
   
  String   __fastcall   TDllCall::AddPOSRecord(int   nCount,   POSRECORD   CardRecord)  
  {  
          String   str,   strPersonID,   strFlowID1,   strFlowID2;  
   
  return   str;  
   
  }  
   
  int   __fastcall   TDllCall::WriteAttGuardFile(int   nCount,   ATTGUARDRECORD   CardRecord)  
  {  
          String   strRecord,   strPersonID,   strFlowID1,   strFlowID2;  
          String   strFlag   =   "0";  
  SYSTEMTIME   LocalTime;  
  GetLocalTime(&LocalTime);  
          String   strCount   =   AddZero(IntToStr(nCount),   5);  
          for   (int   nLoop   =   0;   nLoop   <   7;   nLoop   ++)  
                  strPersonID   +=   CardRecord.tPersonID.str[nLoop];  
          String   strYear   =   AddZero(IntToStr(CardRecord.nYear),   4);  
          String   strMonth   =   AddZero(IntToStr(CardRecord.nMonth),   2);  
          String   strDay   =   AddZero(IntToStr(CardRecord.nDay),   2);  
          String   strHour   =   AddZero(IntToStr(CardRecord.nHour),   2);  
          String   strMinute   =   AddZero(IntToStr(CardRecord.nMinute),   2);  
          String   strSecond   =   AddZero(IntToStr(CardRecord.nSecond),   2);  
          String   strAdr   =   AddZero(IntToStr(CardRecord.nAdr),   3);  
          String   strIsOnDuty,   strIsBC;      
          if(CardRecord.bOnDuty)  
                  strIsOnDuty   =   "1";  
          else  
                  strIsOnDuty   =   "0";  
          if(CardRecord.bBC)  
                  strIsBC   =   "1";  
          else  
                  strIsBC   =   "0";  
          if(LocalTime.wYear   !=   CardRecord.nYear)  
                  strFlag   =   "1";  
          if(LocalTime.wMonth   !=   CardRecord.nMonth)  
                  strFlag   =   "1";  
          if(LocalTime.wDay   !=   CardRecord.nDay)  
                  strFlag   =   "1";  
          if(CardRecord.nHour   >   23   ||   CardRecord.nHour   <   0)  
                  strFlag   =   "1";  
          if(CardRecord.nMinute   >   59   ||   CardRecord.nMinute   <   0)  
                  strFlag   =   "1";  
   
          strFlowID1   =   strYear.SubString(3,   2)   +   strMonth   +   strDay;  
          strFlowID2   =   strAdr   +   strCount;  
        strRecord   =   strFlowID1   +   strFlowID2   +   ","   +   strPersonID   +   ","   +   strYear   +   "-"   +   strMonth   +   "-"   +  
                        strDay   +   ","   +   strHour   +   ":"   +   strMinute   +   ":"   +   strSecond   +   ","   +   strIsOnDuty   +   ","   +  
                        strIsBC   +   ","   +   strFlag   +   "\r\n";  
          FileSeek(nFileHandle1,   0,   2);  
          return   FileWrite(nFileHandle1,   strRecord.c_str(),   strRecord.Length());  
  }  
   
  int   __fastcall   TDllCall::WritePOSFile(int   nCount,POSRECORD   CardRecord)  
  {  
   
          String   strRecord;  
          String   strFlag   =   "0";  
  SYSTEMTIME   LocalTime;  
  GetLocalTime(&LocalTime);  
  //序号  
          String   strCount   =   AddZero(IntToStr(nCount),   5);  
  //帐号  
          String   strCardID   =   AddZero(IntToStr(CardRecord.nInfoID),   6);  
  //消费额  
          String   strConsumeMoney   =   AddZero(IntToStr(CardRecord.nMoneyCent),   5);  
  //余额  
          String   strBlance   =   AddZero(IntToStr(CardRecord.nBalance),   6);  
  //消费流水号  
          String   strTotalCount   =   AddZero(IntToStr(CardRecord.nTotalTimes),   5);  
  //操作员号  
          String   strOpert   =   AddZero(IntToStr(CardRecord.nOperatorNum),   3);  
  //date   ,   time  
          String   strYear   =   AddZero(IntToStr(CardRecord.nYear),   4);  
          String   strMonth   =   AddZero(IntToStr(CardRecord.nMonth),   2);  
          String   strDay   =   AddZero(IntToStr(CardRecord.nDay),   2);  
          String   strHour   =   AddZero(IntToStr(CardRecord.nHour),   2);  
          String   strMinute   =   AddZero(IntToStr(CardRecord.nMinute),   2);  
          String   strSecond   =   AddZero(IntToStr(CardRecord.nSecond),   2);  
   
          String   strAdr   =   AddZero(IntToStr(CardRecord.nDMAdr),   3);  
          String   strNormal,   strCancel;    
          String   strReload;  
   
          if(CardRecord.bNormal)  
                  strNormal   =   "1";  
          else  
                  strNormal   =   "0";  
          if(CardRecord.bCancel)  
                  strCancel   =   "1";  
          else  
                  strCancel   =   "0";  
          if(CardRecord.bReload)  
                  strReload   =   "1";  
          else  
                  strReload   =   "0";  
  //非法日期、时间判断  
          if(LocalTime.wYear   !=   CardRecord.nYear)  
                  strFlag   =   "1";  
          if(LocalTime.wMonth   !=   CardRecord.nMonth)  
                  strFlag   =   "1";  
          if(LocalTime.wDay   !=   CardRecord.nDay)  
                  strFlag   =   "1";  
          if(CardRecord.nHour   >   23   ||   CardRecord.nHour   <   0)  
                  strFlag   =   "1";  
          if(CardRecord.nMinute   >   59   ||   CardRecord.nMinute   <   0)  
                  strFlag   =   "1";  
   
        strRecord   =   strCount   +   ","   +   strCardID   +   ","   +   strConsumeMoney   +   ","  
                                +   strBlance   +   ","   +   strTotalCount   +   ","   +   strOpert   +   ","   +  
                                strYear   +   "-"   +   strMonth   +   "-"   +   strDay   +   ","   +  
                                strHour   +   ":"   +   strMinute   +   ":"   +   strSecond   +   ","   +  
                                strNormal   +   ","   +   strCancel   +   ","   +   strReload   +   ","   +  
                                strFlag   +   ","   +   strAdr   +   "\r\n";  
          FileSeek(nFileHandle1,   0,   2);  
          return   FileWrite(nFileHandle1,   strRecord.c_str(),   strRecord.Length());  
  }Top

2 楼bbm011(只爱花香)回复于 2005-11-18 13:49:55 得分 0

请高人帮忙转换一下,转一部分也可以Top

3 楼lextm(LeLe)回复于 2005-11-18 14:54:14 得分 0

作出DLL来调用不是很方便?翻译反而费时间。大家都很忙的。Top

4 楼constantine(飘遥的安吉儿)回复于 2005-11-19 11:44:17 得分 50

这里太多了,我没有那么多时间,另外你这里的dll里面的函数指针也没有定义  
  都不是很复杂的东西,自己一句一句改过去就可以了Top

相关问题

  • delphi转C++Builder?
  • C++ Builder 转 Delphi
  • C++builder到Delphi的转换
  • C++builder到Delphi的转换!
  • C++ Builder向Delphi的转变
  • 请问:由c++builder转delphi?
  • C++ Builder函数转成 Delphi
  • Delphi To c++builder?
  • C++ Builder 与 Delphi
  • 把Delphi函数转换成C++ builder 我对Delphi不熟.

关键词

  • null
  • hlibrary
  • ninfocode
  • getprocaddress
  • strresult
  • cardrecord
  • fastcall tdllcall
  • chchar
  • nrecvsuccess
  • nrecvempty

得分解答快速导航

  • 帖主:bbm011
  • constantine

相关链接

  • Delphi类图书
  • Delphi类源码下载
  • Delphi控件下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo