INFO: ??????? _declspec(dllimport) & _declspec(dllexport) ?? ?????

?????? ????????? ?????? ?????????
???? ???????: 132044 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ??????? ????? ?? ??????? ??????? ?? "????? ??????? ?? Microsoft:
107501INFO: __export ????????? ??? __declspec ?? Visual C++ 32-??
?????? ??? ??????? ????? ? mechanics ???????? _declspec(dllimport) _declspec(dllexport) ?? ??????? ????? ??.

??????? ????

?????? ????? 32 ?? ?? Visual C++ _declspec(dllimport) ? _declspec(dllexport) ??????? ?????? ???????? __export ?????? ????????? ?? ??????? Visual C++ 16-??.

?? ????? ???????? _declspec(dllimport) ?????? ??? ????????? ???????? ????? ???? ???? ???? ?????? ???? ???? ?????? ??????? ??????? ?????? ??????? ?????? ????. ?? ?????? ??????? ????? ??????? ?????? ???? ???? ??? ???? ??? ?????? ?? ?? ??? ??? ???? ???? ?? DLL ?? ??, ???? ???? ?? ???? ?????? ??????? ???? ???? ????? indirection ????? ???? ?????? ?? ??????? ???? ??????? ?? DLL.

?? ???????? .DEF ??? ????? ??????? _declspec(dllexport) ??? ?????. ??? ????? _declspec(dllexport) ?????? ????? ???? ?????? ??????? ?? .EXE ?? .DLL ???? ??????? ??? .DEF.

???? ????? ??????? ?? ??? ??????? ??? ?????? ???? ?????? ??? ??????? ??????? ?? ??? ????????.

?? ????? ????? ???? ??????? ???????? Win32 ?????? ??? ??????? ???? ??? ?? ???? touched ?????? ?????????. ?????? ????? ??? ??? ???? ?????? ??????? ?? ?????? ?? ???? ???? ???? "???? ??????? ????????". ???? ??? ??????? ?????? ????? ???? ?? ????? ??? ??? ?????? ??? ??? ?????????.

???????? _declspec(dllimport) ??????????? ????

?? ???? ???????? ???????? ?????? ????? func1 ?? ???? ?? DLL ????? ?? ????? (& .EXE) ???? ????? ??? ???? main().

???? _declspec(dllimport) ? ??? ??? ???????? ????????:
void main(void) {
    func1();
}
				
?????? ??????? ???? ??? ??? ???:
call func1
				
? linker ????? ????????? ?? ??? ?? ??? ???:
call 0x4000000         ; The address of 'func1'.
				
If 'func1' ??????? ?? DLL ???, linker ?? ???? ?? ??? ?????? ???? ????? ??? ??? ????? ????? ?? ????? 'func1'. ?? ????? 16-?? ???? linker ??? ??????? ????????? ???????? ??? ????? ?? .EXE ????? ??????? ????? ??? ??????? ???????? ??????? ??????. ?? ????? 32 ?? ?????? linker thunk ???? ???? ???????. thunk ???? ??? ???:
   0x40000000:    jmp DWORD PTR __imp_func1
				
??? __imp_func1 ?? ????? ???? ????? func1 ?? ???? ????? ????????? ?? ????? (& .EXE). ???? ???? ?????? ???????? ??? ????. ??? ??????? ??? ?????? ???? ????? ??????? ????? (& .EXE) ??? ??? ??????? ?? ??? ???? ???? ????.

?????? ???????? _declspec(dllimport) ???? ???? ?? ?????? ??? linker ?? ???? ??? ????? thunk ??? ?? ??? ???. thunks ????? ????????? ???????? (??? ????? RISC ???? ?? ???? ????????? ???) ???? ??? ????? ???? ????? ??????? ??????. ??? ???? ?????? ??????? ?????? ??? DLL ???? ???? ????? ????? ??? ????? ??.

??? ??? ??? ????:
__declspec(dllimport) void func1(void);

void main(void) {
    func1();
}
				
?????? ??? ?????????:
call DWORD PTR __imp_func1
				
???? ?? thunk ? ?? ?????? ???????? ?????? ??? ???????? ???????? ???? ?????.

??? ????? ????? ??????? ?????????? ?????? ???? DLL ??? ????? ??? ????? ???? ??????? ????? ??? ?????. ??? ??? ??? ???? ????? ???? ???????. ?????? ????? ?????? ?? ????? ????? ?????? ??? ????? ??? ????? ???????? ??? ??? ??????? ????? ????? ???? ?? ????. ??? ???? ??? ??????? __declspec(dllimport) ??? ??????? ????? DLL ?? ?????? DLL ????. ?? ?????? __declspec(dllimport) ??? ????? ???? DLL ??? ????? ??? DLL.

???????? _declspec(dllexport)

????? Microsoft __export ?? ????? ?????? ??????? ??????? 16-?? ?????? ??????? ????? ????? ??????? ???????? ?????? ?? ??? .LIB. ???? ??????? ??? ????? .LIB ?? ??? .LIB ????? ???? ?? DLL.

????? Microsoft __declspec(dllexport) ??????? ??? ????????. ????? ??? ?????? ????? ??????? ??? ??? ?????? ???? ?? ????? ??? ??? .DEF.

????? ????? ??? ?????? ???? ??? ?????? ????? ????? ????? ??????? C++. ?? ???? ??? ??????? ???????? ????? ??? ??? ???? ????? ??? ???? ?? ??????? ??? ????????? ?????? ??????? ???????. ??? ??? ?????? _declspec(dllexport) ????? DLL ???????? .EXE ???????? ??????? ??? ???? ?? ????? ?????? ???????.

????? ?????? ?? ?????? ??? ????? ??????? ?? NONAME ??? ? ??? ?? ??? .DEF ???? ???? ????? ?????? ??? ?????? ??? ??? .DEF. ??? ???? ???????? _declspec(dllexport) ???????? ??? ??????? ??? .DEF ?? ???? ????? ???????.

????? ? ????? ???? ??? ????? WINBASE.H Win32. ??? ????? ????? __declspec(dllexport) ??????? ???????? __declspec(dllimport).

???????? _declspec(dllexport) _declspec(dllimport) ??? ????????

?? ???? ???? ????????? ??????? _declspec(dllimport) ?? ???? ???????? ???? ???? indirection. ??? ??????? ?????? ?? ??? DLL ???? ?? ???? ???????? ???? ???? ????? ?????????. ?? ?????? Win32 ??? _declspec(dllimport) ??? ???? ???? ???? ????? ????? ????? ?? indirection ??? ?????? ??? ???????? ?? ??????? ?? DLL:
// project.h
#ifdef _DLL     // If accessing the data from inside the DLL
   ULONG ulDataInDll;

else            // If accessing the data from outside the DLL
   ULONG *ulDataInDll;
#endif
				
?? ????? ????? ???????? ?? ?? ??? .DEF:
// project.def
LIBRARY project
EXPORTS
    ulDataInDll   CONSTANT
				
?????? ???? DLL:
if (*ulDataInDll == 0L) {
   // Do stuff here
}
				
??? ??? ????? ??? ???????? ?? __declspec(dllimport) ?????? ??????? ???????? ?????? ????????? ???????? indirection ??. ?? ??? ???? ??? ????? ???? ??????? ???????? ?????. ??? ?? ????? ?????? ?? ?????? ????? _declspec(dllimport) ??? ???????? ??? ????? DLL. ?? ?????? ??????? ??? DLL "???? ???????? ???????" ?????? ??? ???? ????????. ????? ?? ??? ????? ????? ?? indirection ??????.

?????? ???????? ???????? ?? DLL ?????? ??? ???????:
__declspec(dllexport) ULONG ulDataInDLL;
				

??????? ??? .DEF

??? ????? ??????? __declspec(dllimport) ?? ??? .DEF ??? ????? ??? .DEF ???????? ?????? ????? ?? ???? ?????? ?????? ?? ??????? ??? ????? ?????? ?????:
// project.def
LIBRARY project
EXPORTS
    ulDataInDll   DATA
				
???? ??????? ?????? ???:
Keyword     Emits in the import lib     Exports
CONSTANT    __imp_ulDataInDll           ulDataInDll
            __ulDataInDll

DATA        __imp_ulDataInDll           ulDataInDll
				
??????? _declspec (dllimport) ? ???? ???? ?? ?? ??????? __imp_ ?????? undecorated ?? ????? ????????? .LIB DLL ???? ?? ????? ?????? ??? ????. ???????? _declspec(dllimport) "?" DATA ???? ??????? __imp_ ??? ???.

??? ??? ?????? ???? ??? ???????? ???? ???? ????????? ???????? ??????? ???? ????????? ?????? ??? ulDataInDll:
__declspec(dllimport) ULONG ulDataInDll; /*prototype*/ 
   if (ulDataInDll == 0L)   /*sample code fragment*/ 
				
- ?? -
ULONG *ulDataInDll;      /*prototype*/ 
if (*ulDataInDll == 0L)  /*sample code fragment*/ 
				
??? ???? ??? ??? ?????? ?????? ?? ??? .DEF ???? ?????? ???????? ???????? ?? ????? ??????? ulDataInDll ?????:
__declspec(dllimport) ULONG ulDataInDll;
if (ulDataInDll == 0L)   /*sample code fragment*/ 
				
"??????? ????" ??? ???????? ???? ???? ??? ???? ???????? ????? ????? indirection ?? ????? ?? ???? ?????? ?????? "???? ??????? ????????" ??? ?????--??? ????? ????. ???? ?????? ?????? ??? ????? ?? ??????? ??? "?????? ????" ??? "???? ???????? ???????" ?? ?????? ??????? ??? ?????? ?????? ??????? Microsoft linkers.

?????? linker ?????? Visual C++ ????? ??? ??? ????? ???? ?? ??? .DEF ????? ??? ??????. ????? ??????? ??? ???????? ???? ?? ??? ?? ???? ????? ????? ??? ?????? ??? ??? ?? ??? ??? ????? dllimport ??? ??????? ??????.

?????

Visual C++ ???????? ???? ????? ????? ?????? ??? dllexport ? dllimport ???? ??? ?????. ????? "dllexport ? dllimport ????" ? "??????? dllimport ? dllexport ?? C++" ???????? ?? ????? "???????? ????? ?? Microsoft" ????? ??? C++ ??????? "???? ?????" ?? ????? "????? DLLs ?? Win32" ?????? "?????? ???????". ?????? ??? ????? ???? ????? ??????? ???????? "dllimport" ?? "dllexport" ???????? ??? ?????.

????? ?? ?????????? ?????? ?????? ???????? ??????? ?? "????? ????? Microsoft:
90530????? ????? ???????? ?? DLL "??" ?????
107501INFO: __export ????????? ??? __declspec ?? Visual C++ 32-??

???????

???? ???????: 132044 - ????? ??? ??????: 08/????/1424 - ??????: 2.0
????? ???
  • Microsoft Visual C++ 1.0 Professional Edition
  • Microsoft Visual C++ 2.0 Professional Edition
  • Microsoft Visual C++ 2.1
  • Microsoft Visual C++ 4.0 Standard Edition
  • Microsoft Visual C++ 5.0 Enterprise Edition
  • Microsoft Visual C++ 5.0 Professional Edition
????? ??????: 
kbmt kbcode kbcompiler kbinfo KB132044 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????132044
????? ??????? ?? ????? ???? ?? ????? ???????
?? ????? ????? ?????? ???? ???? ???? ??? ??????? ??? ?? ? ?? ??? ??????? Microsoft ??? ????? ??? ??????? ????? ?????? ?????

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com