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 閱讀(1180) 評論(0)  編輯  收藏 所屬分類: javaLinux/C
          主站蜘蛛池模板: 花莲市| 黑龙江省| 汕尾市| 栖霞市| 藁城市| 合肥市| 兴业县| 饶平县| 永兴县| 黄山市| 东丰县| 竹北市| 宜兰市| 蓬溪县| 启东市| 轮台县| 团风县| 三江| 镇康县| 永泰县| 山阳县| 浦东新区| 罗平县| 行唐县| 通许县| 论坛| 韶山市| 罗江县| 石柱| 乌什县| 鄂伦春自治旗| 华容县| 增城市| 莱芜市| 云阳县| 湟源县| 六枝特区| 甘孜县| 临桂县| 顺昌县| 南靖县|