DllManager.cpp
上传用户:hyb6888
上传日期:2016-01-24
资源大小:5186k
文件大小:4k
源码类别:

输入法编程

开发平台:

Visual C++

  1. // mydebug.cpp : Defines the entry point for the console application.
  2. //
  3. #include "stdafx.h"
  4. #include "windows.h"
  5. #include "stdio.h"
  6. #include "DllManager.h"
  7. DllManager:: DllManager()
  8. {
  9. int ret=0;
  10. HANDLE fd1;
  11. WIN32_FIND_DATAA tt ;
  12. hkeyDLL=NULL;
  13.   LoadErr=0;
  14.   // MessageBox (0,"Load TranChiDll.dll",0,0);
  15. fd1=FindFirstFile("c:\jsime\TranChiDll.dll",&tt);
  16.     if(fd1==INVALID_HANDLE_VALUE)
  17. {
  18.    //MessageBox(0,"文件TranChiDll.dll未找到!n 请立即保存,系统可能崩溃!?","c:\jsime\",0);
  19.    LoadErr=1;
  20. }
  21. else
  22. {
  23. hkeyDLL=LoadLibrary("c:\jsime\TranChiDll.dll");//加载动态链接库.dll文件; 
  24. m_creat=(m_pcreat)GetProcAddress(hkeyDLL,"creat"); 
  25. m_ChissToCodeC =(m_pChissToCodeC)GetProcAddress(hkeyDLL,"ChissToCodeC"); 
  26. m_DLLstart     =(m_pDLLstart)GetProcAddress(hkeyDLL,"DLLstart"); 
  27. m_SetIMEModle=(m_pSetIMEModle)GetProcAddress(hkeyDLL,"SetIMEModle"); 
  28. m_keyprogress=(m_pkeyprogress)GetProcAddress(hkeyDLL,"keyprogress"); 
  29. m_getnextpage=(m_pgetnextpage)GetProcAddress(hkeyDLL,"getnextpage"); 
  30. m_myclearbuf=(m_pClearBuf)GetProcAddress(hkeyDLL,"ClearBuf"); 
  31. m_creatNotest=(m_pcreatNotest)GetProcAddress(hkeyDLL,"creatNotest"); 
  32. m_insertNewWord=(m_pinsertNewWord)GetProcAddress(hkeyDLL,"insertNewWord"); 
  33. }
  34. }
  35. DllManager:: ~DllManager()
  36. {
  37. if(NULL!=hkeyDLL)
  38. {
  39. FreeLibrary(hkeyDLL);//卸载TranChiDll.dll文件;
  40. hkeyDLL=NULL;
  41. //MessageBox (0,"FreeLibrary",0,0);
  42. }
  43. }
  44. BOOL DllManager::creatNotest(char *CodeSource,char *userdefine,char *ExCodeSource,char *Code,long base, long goldeNum, long goldeLen)
  45. {
  46. BOOL ret=0;
  47. if(LoadErr==1)
  48. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  49. else
  50. ret=m_creatNotest(CodeSource,userdefine,ExCodeSource,Code,base, goldeNum, goldeLen);
  51. return ret;
  52. }
  53. BOOL DllManager::creat(char *CodeSource,char *userdefine,char *ExCodeSource,char *Code,long base, long goldeNum, long goldeLen)
  54. {
  55. BOOL ret=0;
  56. if(LoadErr==1)
  57. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  58. else
  59. ret=m_creat(CodeSource,userdefine,ExCodeSource,Code, base, goldeNum, goldeLen);
  60. return ret;
  61. }
  62. /////////////////////////////////////////////////
  63. BOOL DllManager::insertNewWord(char *En,char *chi)
  64. {
  65. BOOL ret=0;
  66. if(LoadErr==1)
  67. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  68. else
  69. ret=  m_insertNewWord(En,chi);
  70. return ret;
  71. }
  72. BOOL DllManager::DLLstart   (int update)
  73. {
  74. BOOL ret=0;
  75. if(LoadErr==1)
  76. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  77. else
  78. ret=  m_DLLstart( update);
  79. return ret;
  80. }
  81. BOOL DllManager::SetIMEModle(int Mode)
  82. {
  83. BOOL ret=0;
  84. if(LoadErr==1)
  85. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  86. else
  87. ret=  m_SetIMEModle(Mode);
  88. return ret;
  89. }
  90. BOOL DllManager::keyprogress(int wparam,char*ss,char *SendENbuf, char* SendCH,char *Midtems,char* Control) //int wparam
  91. {
  92. BOOL ret=0;
  93. if(LoadErr==1)
  94. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  95. else
  96. ret=  m_keyprogress(wparam,ss,SendENbuf, SendCH,Midtems,Control) ;
  97. return ret;
  98. }
  99. BOOL DllManager::getnextpage( char *Midtems,int torword)
  100. {
  101. BOOL ret=0;
  102. if(LoadErr==1)
  103. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  104. else
  105. ret=  m_getnextpage(Midtems,torword);
  106. return ret;
  107. }
  108. BOOL DllManager::myclearbuf()
  109. {
  110. BOOL ret=0;
  111. if(LoadErr==1)
  112. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  113. else
  114. ret=  m_myclearbuf();
  115. return ret;
  116. }
  117. BOOL DllManager::ChissToCodeC(char *MainCodeLibName,char *chiss,char *codess)
  118. {
  119. BOOL ret=0;
  120. if(LoadErr==1)
  121. MessageBox(0,"库加载失败函数","c:\jsime\",0);
  122. else
  123. ret= m_ChissToCodeC(MainCodeLibName,chiss,codess);
  124. return ret;
  125. }