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 閱讀(1185) 評論(0)  編輯  收藏 所屬分類: javaLinux/C
          主站蜘蛛池模板: 巴楚县| 四平市| 哈巴河县| 石景山区| 天气| 灵山县| 濮阳市| 攀枝花市| 蛟河市| 兴化市| 桃园市| 榆社县| 漠河县| 白山市| 肥城市| 开化县| 三河市| 廊坊市| 前郭尔| 宝兴县| 洛南县| 临沂市| 房产| 德昌县| 牡丹江市| 邮箱| 栾川县| 疏勒县| 沛县| 砚山县| 阿城市| 枣阳市| 梁河县| 富川| 扎鲁特旗| 淮滨县| 莱州市| 马山县| 汕头市| 邛崃市| 益阳市|