HelloWorld 善戰者,求之于勢,不責于人;故能擇人而任勢。

          知止而后有定,定而后能靜,靜而后能安,安而后能慮,慮而后能得。物有本末,事有終始。知所先后,則近道矣。

            BlogJava :: 首頁 ::  :: 聯系 ::  :: 管理 ::
            167 隨筆 :: 1 文章 :: 40 評論 :: 0 Trackbacks

          #include <windows.h>
          #include "string.h"
          #include "Decode.h"

          #pragma argsused
          typedef int (__stdcall *fun_AddFun)(int Data);
          HINSTANCE gLib = NULL;
          fun_AddFun gFun = NULL;
          int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved){
                  switch(reason) {
                          case DLL_PROCESS_ATTACH: {
                                  char tPath[255];
                                  int tSize;
                                  GetModuleFileName(hinst,tPath,255);
                                  tSize = strlen(tPath)-1;
                                  while(tPath[tSize]!='\\') {
                                          --tSize;
                                  }
                                  tPath[tSize+1] = 0;
                                  strcat(tPath,"Test.dll");

                                  gLib = LoadLibrary(tPath);
                                  if(gLib == NULL) {
                                          MessageBox(NULL,tPath,"Load Library Failed",MB_OK);
                                          return;
                                  }
                                  gFun = (fun_AddFun)GetProcAddress(gLib,"AddFun");
                          }
                          break;
                          case DLL_PROCESS_DETACH: {
                                  if(gLib) {
                                          FreeLibrary(gLib);
                                          gLib = NULL;
                                  }
                          }
                          break;
                  }
                  return 1;
          }

          JNIEXPORT jint JNICALL Java_Encode_Add (JNIEnv *env, jclass cls, jint a, jint b) {
                  if(gFun==NULL)
                          return 0;
                  else {
                          int tRe = gFun(100);
                          return a + b + tRe;
                  }              
          }

           int  __declspec(dllexport) __stdcall fun_x(int a,int b)
          {
                  if(gFun==NULL)
                          return 0;
                  else {
                          int tRe = gFun(100);
                          return a + b + tRe;
                  }              

          }

           



          </script>

          posted on 2007-11-05 15:37 helloworld2008 閱讀(1179) 評論(0)  編輯  收藏 所屬分類: javaLinux/C
          主站蜘蛛池模板: 涟水县| 南开区| 民乐县| 土默特右旗| 乐业县| 治多县| 江川县| 辉县市| 盐城市| 清苑县| 水富县| 微山县| 台湾省| 永州市| 安泽县| 东源县| 化隆| 广丰县| 通海县| 天镇县| 峡江县| 布拖县| 岗巴县| 时尚| 秦皇岛市| 防城港市| 丰宁| 循化| 农安县| 马鞍山市| 资兴市| 耒阳市| 姚安县| 志丹县| 砚山县| 英山县| 万荣县| 香港| 克什克腾旗| 二连浩特市| 荃湾区|