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 閱讀(1190) 評論(0)  編輯  收藏 所屬分類: java 、Linux/C
          主站蜘蛛池模板: 绩溪县| 长治县| 扶余县| 高唐县| 万州区| 监利县| 方城县| 黔西| 富顺县| 东丰县| 左贡县| 陆河县| 广河县| 文化| 社旗县| 保康县| 咸阳市| 海口市| 陆川县| 沅江市| 商城县| 扬州市| 海宁市| 容城县| 武清区| 堆龙德庆县| 湘阴县| 定南县| 忻州市| 道孚县| 祁阳县| 中超| 三门峡市| 锡林浩特市| 女性| 夏邑县| 曲水县| 寿阳县| 秭归县| 建水县| 股票|