I had saved my programs on USB ram sticks.
After downloading FreeBASIC onto the new laptop I tried to run an .exe program that captures images from any web cam.
It worked fine.
However when I tried to compile the source code and run it there was a fail with this error,
can't load 'escapi.dll' !
It is a 64 bit machine.
I am using FreeBASIC-1.09.0-win64
escapi.bi and the escapi.dll are in the same folder as the program being compiled and the escapi.dll in the folder must be being used by the .exe program compiled on my previous computer for the .exe to have worked.
Any ideas?
Code: Select all
#include "escapi.bi"
const SCR_W = 320
const SCR_H = 240
dim as integer nDevices=setupESCAPI()
if nDevices<1 then
print "No active capture device found!"
beep:sleep:end
end if
ScreenRes SCR_W,SCR_H,32
dim as any ptr lpImage=ImageCreate(SCR_W,SCR_H)
dim as SimpleCapParams Params
with Params
.mWidth = SCR_W
.mHeight = SCR_H
.mTargetBuf=cptr(integer ptr,lpImage)
.mTargetBuf+=8
end with
WindowTitle "initCapture=" & str(initCapture(0, @Params))
while inkey<>chr$(27)
doCapture(0)
While isCaptureDone(0)<>1:Sleep(10):Wend
put (0,0),lpImage,pset
wend
Code: Select all
' Extremely Simple Capture API
type SimpleCapParams
' Target buffer.
' Must be at least mWidth * mHeight * sizeof(int) of size!
as integer ptr mTargetBuf
as integer mWidth
as integer mHeight
end type
' Sets up the ESCAPI DLL and the function pointers below. Call this first!
' Returns number of capture devices found (same as countCaptureDevices, below)
declare function setupESCAPI() as integer
' return the number of capture devices found
type countCaptureDevicesProc as function cdecl as integer
dim shared as countCaptureDevicesProc countCaptureDevices
' initCapture tries to open the video capture device.
' Returns 0 on failure, 1 on success.
' Note: Capture parameter values must not change while capture device
' is in use (i.e. between initCapture and deinitCapture).
' Do *not* free the target buffer, or change its pointer!
type initCaptureProc as function cdecl (deviceno as integer,p as SimpleCapParams ptr) as integer
dim shared as initCaptureProc initCapture
' deinitCapture closes the video capture device.
type deinitCaptureProc as sub cdecl(deviceno as integer)
dim shared as deinitCaptureProc deinitCapture
' doCapture requests video frame to be captured.
type doCaptureProc as sub cdecl(deviceno as integer)
dim shared as doCaptureProc doCapture
' isCaptureDone returns 1 when the requested frame has been captured.
type isCaptureDoneProc as function cdecl(deviceno as integer) as integer
dim shared as isCaptureDoneProc isCaptureDone
' Get the user-friendly name of a capture device.
type getCaptureDeviceNameProc as sub cdecl(deviceno as integer,namebuffer as zstring ptr,bufferlength as integer)
dim shared as getCaptureDeviceNameProc getCaptureDeviceName
' Returns the ESCAPI DLL version. 0x200 for 2.0
type ESCAPIDLLVersionProc as function() as integer
dim shared as ESCAPIDLLVersionProc ESCAPIDLLVersion
' Internal: initialize COM
type initCOMProc as sub cdecl
dim shared as initCOMProc initCOM
function setupESCAPI() as integer
' Load DLL dynamically
dim as any ptr capdll = DyLibLoad("escapi.dll")
if (capdll = 0) then
print "can't load 'escapi.dll' !"
beep:sleep:return 0
end if
' Fetch function DyLibSymbol(escapi_dll,
countCaptureDevices = DyLibSymbol(capdll, "countCaptureDevices")
initCapture = DyLibSymbol(capdll, "initCapture")
deinitCapture = DyLibSymbol(capdll, "deinitCapture")
doCapture = DyLibSymbol(capdll, "doCapture")
isCaptureDone = DyLibSymbol(capdll, "isCaptureDone")
initCOM = DyLibSymbol(capdll, "initCOM")
getCaptureDeviceName = DyLibSymbol(capdll, "getCaptureDeviceName")
ESCAPIDLLVersion = DyLibSymbol(capdll, "ESCAPIDLLVersion")
if ESCAPIDLLVersion=0 then
print "can't get proc address !"
beep:sleep:return 0
end if
if (ESCAPIDLLVersion() <> &H200) then
print "wrong dll version !"
beep:sleep:return 0
end if
' Initialize COM.
initCOM()
' and return the number of capture devices found.
return countCaptureDevices()
end function