So, what is the trick for calling functions from System32
64bit DLLs from a library built with C Builder 5?
UPDATE:
Here is evidence that the functions are actually imported from a parent DLL:
UPDATE:
More one evidence:
UPDATE
OK, here is the makefile:
# ---------------------------------------------------------------------------
!if !$d(BCB)
BCB = $(MAKEDIR)\..
!endif
# ---------------------------------------------------------------------------
# IDE SECTION
# ---------------------------------------------------------------------------
# The following section of the project makefile is managed by the BCB IDE.
# It is recommended to use the IDE to change any of the values in this
# section.
# ---------------------------------------------------------------------------
VERSION = BCB.05.03
# ---------------------------------------------------------------------------
PROJECT = maxicef.bpl
OBJFILES = \
# ..\winlib\winlib.obj \
..\addons\MaxiSysUtils.obj \
..\source\uCEFAccessibilityHandler.obj \
..\source\uCEFApp.obj \
..\source\uCEFApplication.obj \
..\source\uCEFApplicationCore.obj \
..\source\uCEFAudioHandler.obj \
..\source\uCEFAuthCallback.obj \
..\source\uCEFBaseRefCounted.obj \
..\source\uCEFBaseScopedWrapper.obj \
..\source\uCEFBeforeDownloadCallback.obj \
..\source\uCEFBinaryValue.obj \
..\source\uCEFBitmapBitBuffer.obj \
..\source\uCEFBoxLayout.obj \
..\source\uCEFBrowser.obj \
..\source\uCEFBrowserProcessHandler.obj \
..\source\uCEFBrowserView.obj \
..\source\uCEFBrowserViewComponent.obj \
..\source\uCEFBrowserViewDelegate.obj \
..\source\uCEFBufferPanel.obj \
..\source\uCEFButton.obj \
..\source\uCEFButtonComponent.obj \
..\source\uCEFButtonDelegate.obj \
..\source\uCEFCallback.obj \
..\source\uCEFChromium.obj \
..\source\uCEFChromiumCore.obj \
..\source\uCEFChromiumEvents.obj \
..\source\uCEFChromiumFontOptions.obj \
..\source\uCEFChromiumOptions.obj \
..\source\uCEFChromiumWindow.obj \
..\source\uCEFClient.obj \
..\source\uCEFCommandLine.obj \
..\source\uCEFCompletionCallback.obj \
..\source\uCEFConstants.obj \
..\source\uCEFContextMenuHandler.obj \
..\source\uCEFContextMenuParams.obj \
..\source\uCEFCookieAccessFilter.obj \
..\source\uCEFCookieManager.obj \
..\source\uCEFCookieVisitor.obj \
..\source\uCEFCustomStreamReader.obj \
..\source\uCEFDeleteCookiesCallback.obj \
..\source\uCEFDevToolsMessageObserver.obj \
..\source\uCEFDialogHandler.obj \
..\source\uCEFDictionaryValue.obj \
..\source\uCEFDisplay.obj \
..\source\uCEFDisplayHandler.obj \
..\source\uCEFDomDocument.obj \
..\source\uCEFDomNode.obj \
..\source\uCEFDomVisitor.obj \
..\source\uCEFDownLoadItem.obj \
..\source\uCEFDownloadHandler.obj \
..\source\uCEFDownloadImageCallBack.obj \
..\source\uCEFDownloadItemCallback.obj \
..\source\uCEFDragAndDropMgr.obj \
..\source\uCEFDragData.obj \
..\source\uCEFDragHandler.obj \
..\source\uCEFEndTracingCallback.obj \
..\source\uCEFExtension.obj \
..\source\uCEFExtensionHandler.obj \
..\source\uCEFFileDialogCallback.obj \
..\source\uCEFFillLayout.obj \
..\source\uCEFFindHandler.obj \
..\source\uCEFFocusHandler.obj \
..\source\uCEFFrame.obj \
..\source\uCEFFrameHandler.obj \
..\source\uCEFGetExtensionResourceCallback.obj \
..\source\uCEFImage.obj \
..\source\uCEFInterfaces.obj \
..\source\uCEFJsDialogCallback.obj \
..\source\uCEFJsDialogHandler.obj \
..\source\uCEFJson.obj \
..\source\uCEFKeyboardHandler.obj \
..\source\uCEFLabelButton.obj \
..\source\uCEFLabelButtonComponent.obj \
..\source\uCEFLayout.obj \
..\source\uCEFLibFunctions.obj \
..\source\uCEFLifeSpanHandler.obj \
..\source\uCEFLinkedWinControlBase.obj \
..\source\uCEFLinkedWindowParent.obj \
..\source\uCEFListValue.obj \
..\source\uCEFLoadHandler.obj \
..\source\uCEFMediaObserver.obj \
..\source\uCEFMediaRoute.obj \
..\source\uCEFMediaRouteCreateCallback.obj \
..\source\uCEFMediaRouter.obj \
..\source\uCEFMediaSink.obj \
..\source\uCEFMediaSinkDeviceInfoCallback.obj \
..\source\uCEFMediaSource.obj \
..\source\uCEFMenuButton.obj \
..\source\uCEFMenuButtonComponent.obj \
..\source\uCEFMenuButtonDelegate.obj \
..\source\uCEFMenuButtonPressedLock.obj \
..\source\uCEFMenuModel.obj \
..\source\uCEFMenuModelDelegate.obj \
..\source\uCEFMiscFunctions.obj \
..\source\uCEFNavigationEntry.obj \
..\source\uCEFNavigationEntryVisitor.obj \
..\source\uCEFOAuth2Helper.obj \
..\source\uCEFOLEDragAndDrop.obj \
..\source\uCEFOSRIMEHandler.obj \
..\source\uCEFOverlayController.obj \
..\source\uCEFPDFPrintCallback.obj \
..\source\uCEFPDFPrintOptions.obj \
..\source\uCEFPanel.obj \
..\source\uCEFPanelComponent.obj \
..\source\uCEFPanelDelegate.obj \
..\source\uCEFPostData.obj \
..\source\uCEFPostDataElement.obj \
..\source\uCEFPrintDialogCallback.obj \
..\source\uCEFPrintHandler.obj \
..\source\uCEFPrintJobCallback.obj \
..\source\uCEFPrintSettings.obj \
..\source\uCEFProcessMessage.obj \
..\source\uCEFRegistration.obj \
..\source\uCEFRenderHandler.obj \
..\source\uCEFRenderProcessHandler.obj \
..\source\uCEFRequest.obj \
..\source\uCEFRequestContext.obj \
..\source\uCEFRequestContextHandler.obj \
..\source\uCEFRequestHandler.obj \
..\source\uCEFResolveCallback.obj \
..\source\uCEFResourceBundle.obj \
..\source\uCEFResourceBundleHandler.obj \
..\source\uCEFResourceHandler.obj \
..\source\uCEFResourceReadCallback.obj \
..\source\uCEFResourceRequestHandler.obj \
..\source\uCEFResourceSkipCallback.obj \
..\source\uCEFResponse.obj \
..\source\uCEFResponseFilter.obj \
..\source\uCEFRunContextMenuCallback.obj \
..\source\uCEFRunFileDialogCallback.obj \
..\source\uCEFSSLStatus.obj \
..\source\uCEFSchemeHandlerFactory.obj \
..\source\uCEFSchemeRegistrar.obj \
..\source\uCEFScrollView.obj \
..\source\uCEFScrollViewComponent.obj \
..\source\uCEFSelectClientCertificateCallback.obj \
..\source\uCEFSentinel.obj \
..\source\uCEFServer.obj \
..\source\uCEFServerComponent.obj \
..\source\uCEFServerEvents.obj \
..\source\uCEFServerHandler.obj \
..\source\uCEFSetCookieCallback.obj \
..\source\uCEFSslInfo.obj \
..\source\uCEFStreamReader.obj \
..\source\uCEFStreamWriter.obj \
..\source\uCEFStringList.obj \
..\source\uCEFStringMap.obj \
..\source\uCEFStringMultimap.obj \
..\source\uCEFStringVisitor.obj \
..\source\uCEFTask.obj \
..\source\uCEFTaskRunner.obj \
..\source\uCEFTextfield.obj \
..\source\uCEFTextfieldComponent.obj \
..\source\uCEFTextfieldDelegate.obj \
..\source\uCEFThread.obj \
..\source\uCEFTimerWorkScheduler.obj \
..\source\uCEFTypes.obj \
..\source\uCEFUrlRequest.obj \
..\source\uCEFUrlRequestClientComponent.obj \
..\source\uCEFUrlRequestClientEvents.obj \
..\source\uCEFUrlrequestClient.obj \
..\source\uCEFValue.obj \
..\source\uCEFView.obj \
..\source\uCEFViewComponent.obj \
..\source\uCEFViewDelegate.obj \
..\source\uCEFViewsFrameworkEvents.obj \
..\source\uCEFWaitableEvent.obj \
..\source\uCEFWebPluginInfo.obj \
..\source\uCEFWebPluginInfoVisitor.obj \
..\source\uCEFWebPluginUnstableCallback.obj \
..\source\uCEFWinControl.obj \
..\source\uCEFWindow.obj \
..\source\uCEFWindowComponent.obj \
..\source\uCEFWindowDelegate.obj \
..\source\uCEFWindowParent.obj \
..\source\uCEFWorkScheduler.obj \
..\source\uCEFWorkSchedulerQueueThread.obj \
..\source\uCEFWorkSchedulerThread.obj \
..\source\uCEFWriteHandler.obj \
..\source\uCEFX509CertPrincipal.obj \
..\source\uCEFX509Certificate.obj \
..\source\uCEFXmlReader.obj \
..\source\uCEFZipReader.obj \
..\source\uCEFv8Accessor.obj \
..\source\uCEFv8ArrayBufferReleaseCallback.obj \
..\source\uCEFv8Context.obj \
..\source\uCEFv8Exception.obj \
..\source\uCEFv8Handler.obj \
..\source\uCEFv8Interceptor.obj \
..\source\uCEFv8StackFrame.obj \
..\source\uCEFv8StackTrace.obj \
..\source\uCEFv8Value.obj \
..\packages\CEF4Delphi_Register.obj \
maxicef.obj
RESFILES = maxicef.res ..\packages\res\chromium.dcr
MAINSOURCE = maxicef.cpp
RESDEPEN = $(RESFILES)
LIBFILES =
IDLFILES =
IDLGENFILES =
LIBRARIES = Rxctl5.lib
PACKAGES = vcl50.bpi
SPARELIBS = Vcl50.lib Rxctl5.lib
DEFFILE =
# ---------------------------------------------------------------------------
PATHCPP = .;..\winlib;
PATHASM = .;
PATHPAS = .;..\source;..\packages;..\addons;
PATHRC = .;..\packages\res;
DEBUGLIBPATH = $(BCB)\lib\debug;
RELEASELIBPATH = $(BCB)\lib\release
USERDEFINES = _DEBUG;MSWINDOWS;CPUX32;TARGET_32BITS;VER130;
SYSDEFINES = _RTLDLL;NO_STRICT;USEPACKAGES
INCLUDEPATH = ..\source;..\packages;..\addons;..\winlib;$(BCB)\include;$(BCB)\include\vcl
LIBPATH = ..\source;..\packages;..\packages\res;..\addons;..\winlib;c:\windows\system32;c:\windows\SysWOW64;L:\Lib;$(BCB)\lib\obj;$(BCB)\lib;
WARNINGS= -w-par
# ---------------------------------------------------------------------------
CFLAG1 = -Od -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi- -c -tWM -H=vcl50.csm
IDLCFLAGS = -I..\source -I..\packages -I..\addons -I..\winlib -I$(BCB)\include -I$(BCB)\include\vcl \
-src_suffix cpp -D_DEBUG -DMSWINDOWS -DCPUX32 -DTARGET_32BITS -DVER130 -boa
PFLAGS = -$YD -$W -$O- -v -JPHNE -M
RFLAGS =
AFLAGS = /mx /w2 /zd
LFLAGS = -D"" -aa -Tpp -x -Gn -Gl -Gi -v
# ---------------------------------------------------------------------------
ALLOBJ = c0pkg32.obj $(PACKAGES) Memmgr.Lib sysinit.obj $(OBJFILES)
ALLRES = $(RESFILES)
ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib
# ---------------------------------------------------------------------------
!ifdef IDEOPTIONS
[Version Info]
IncludeVerInfo=0
AutoIncBuild=0
MajorVer=1
MinorVer=0
Release=0
Build=0
Debug=0
PreRelease=0
Special=0
Private=0
DLL=0
[Version Info Keys]
CompanyName=
FileDescription=
FileVersion=1.0.0.0
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=1.0.0.0
Comments=
[Debugging]
DebugSourceDirs=$(BCB)\source\vcl
!endif
# ---------------------------------------------------------------------------
# MAKE SECTION
# ---------------------------------------------------------------------------
# This section of the project file is not used by the BCB IDE. It is for
# the benefit of building from the command-line using the MAKE utility.
# ---------------------------------------------------------------------------
.autodepend
# ---------------------------------------------------------------------------
!if "$(USERDEFINES)" != ""
AUSERDEFINES = -d$(USERDEFINES:;= -d)
!else
AUSERDEFINES =
!endif
!if !$d(BCC32)
BCC32 = bcc32ide
!endif
!if !$d(CPP32)
CPP32 = cpp32
!endif
!if !$d(DCC32)
DCC32 = dcc32
!endif
!if !$d(TASM32)
TASM32 = tasm32
!endif
!if !$d(LINKER)
LINKER = ilink32
!endif
!if !$d(BRCC32)
BRCC32 = brcc32
!endif
# ---------------------------------------------------------------------------
!if $d(PATHCPP)
.PATH.CPP = $(PATHCPP)
.PATH.C = $(PATHCPP)
!endif
!if $d(PATHPAS)
.PATH.PAS = $(PATHPAS)
!endif
!if $d(PATHASM)
.PATH.ASM = $(PATHASM)
!endif
!if $d(PATHRC)
.PATH.RC = $(PATHRC)
!endif
# ---------------------------------------------------------------------------
$(PROJECT): $(IDLGENFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE)
$(BCB)\BIN\$(LINKER) @&&!
$(LFLAGS) -L$(LIBPATH)
$(ALLOBJ),
$(PROJECT),,
$(ALLLIB),
$(DEFFILE),
$(ALLRES)
!
# ---------------------------------------------------------------------------
.pas.hpp:
$(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< }
.pas.obj:
$(BCB)\BIN\$(DCC32) $(PFLAGS) -U$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -O$(INCLUDEPATH) --BCB {$< }
.cpp.obj:
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< }
.c.obj:
$(BCB)\BIN\$(BCC32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< }
.c.i:
$(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< }
.cpp.i:
$(BCB)\BIN\$(CPP32) $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n. {$< }
.asm.obj:
$(BCB)\BIN\$(TASM32) $(AFLAGS) -i$(INCLUDEPATH:;= -i) $(AUSERDEFINES) -d$(SYSDEFINES:;= -d) $<, $@
.rc.res:
$(BCB)\BIN\$(BRCC32) $(RFLAGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -fo$@ $<
# ---------------------------------------------------------------------------
UPDATE
For @PaulMcKenzie: I have a 64bit OS, and I need to build a 32bit application with Borland C Builder 5 to run on the 64bit OS. The problem I have is the issue with the Unresolved external
errors, when I reference Windows functions residing in Windows DLLs from my .pas
files.
CodePudding user response:
OK, thank you all, for making me understand the process of DLL importing.
As IInspectable
and Remy Lebeau
said - the import of DLL
requires linking with the LIB
.
You need to recreate the .lib
files. I have Borland C builder
installed on T:\
virtual drive:
> cd ..\libs
> T:\Bin\implib.exe kernel32.lib c:\Windows\SysWOW64\kernel32.dll
I put the libs in folder ..\libs
relative to the makefile
.
Third
There is a bug in compiler of Borland
. It fails to compile call to an external function from class method, so you need to add proxies:
unit uCEFMiscFunctions;
interface
const
Kernel32DLL = 'kernel32.dll';
{$IFDEF MSWINDOWS}
function GetGlobalMemoryStatusEx_(lpBuffer: LPMEMORYSTATUSEX): BOOL;
function GetGlobalMemoryStatusEx(lpBuffer: LPMEMORYSTATUSEX): BOOL; stdcall; external Kernel32DLL name 'GlobalMemoryStatusEx';
{$ENDIF}
implementation
{$IFDEF MSWINDOWS}
function GetGlobalMemoryStatusEx_(lpBuffer: LPMEMORYSTATUSEX): BOOL;
begin
Result := GetGlobalMemoryStatusEx(lpBuffer);
end;
{$ENDIF}
unit uCEFApplicationCore;
...
function TCefApplicationCore.GetTotalSystemMemory : UInt64;
{$IFDEF MSWINDOWS}
var
TempMemStatus : TMyMemoryStatusEx;
{$ENDIF}
begin
Result := 0;
{$IFDEF MSWINDOWS}
ZeroMemory(@TempMemStatus, SizeOf(TMyMemoryStatusEx));
TempMemStatus.dwLength := SizeOf(TMyMemoryStatusEx);
if GetGlobalMemoryStatusEx_(@TempMemStatus) then
if True then
Result := TempMemStatus.ullTotalPhys;
{$ENDIF}
end;