Title is No Title

not very good here!

导航

use /Fe create dll file can not be used by WinApp,only can be used by jni.

these type dll can not be used by winApp;
for example,will apear that can not find func;
C:\JNI>cl useDll.cpp user32.lib
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

useDll.cpp
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:useDll.exe
useDll.obj
user32.lib

C:\JNI>useDll

 

 

 

 

 


use Fe can create dll.


C:\JNI>cl secondApp.cpp user32.lib /Fess.dll
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

secondApp.cpp
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:ss.dll
secondApp.obj
user32.lib


///--------------------------------
file1:
// secondApp.cpp : Defines the entry point for the application.
//

#include "windows.h"
void callDll();
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
  // TODO: Place code here.
  callDll();
    ::MessageBox(NULL,"ssssss","ssssssssss",0);
 return 0;
}
int showInfo(){
::MessageBox(NULL,"info","info",0);
return 99;
}
void callDll(){
typedef void (WINAPI * func)();
 HINSTANCE hmod;
 hmod = ::LoadLibrary ("ss.dll");
 if(hmod==NULL)
 {
  MessageBox(NULL,"Fail","Fail",MB_OK);
 }
 func lpproc;
 lpproc = (func)GetProcAddress (hmod,"showInfo");
 if(lpproc!=(func)NULL)
  (*lpproc)();
  else{
  MessageBox(NULL,"can not find func","can not find func",MB_OK);
  }
 
 FreeLibrary(hmod);
}
/*

C:\JNI>cl secondApp.cpp user32.lib /Fess.dll
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

secondApp.cpp
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:ss.dll
secondApp.obj
user32.lib
*/
-------------
file2:

// secondApp.cpp : Defines the entry point for the application.
//

#include "windows.h"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
  // TODO: Place code here.
    ::MessageBox(NULL,"ssssss","ssssssssss",0);
 return 0;
}
int showInfo(){
::MessageBox(NULL,"info","info",0);
return 99;
}
/*

C:\JNI>cl secondApp.cpp user32.lib /Fess.dll
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

secondApp.cpp
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:ss.dll
secondApp.obj
user32.lib
*/

posted on 2004-03-22 16:14  abraham  阅读(669)  评论(0编辑  收藏  举报