I am converting my pascal code to PL/SQL for use with Oracle Forms 6i. My pascal code below, works perfectly.
program WebcamTest;
//cswi
//www.delphibasics.info
const
WM_CAP_DRIVER_CONNECT = 1034;
WM_CAP_GRAB_FRAME = 1084;
WM_CAP_SAVEDIB = 1049;
WM_CAP_DRIVER_DISCONNECT = 1035;
function SendMessageA(hWnd: Integer;
Msg: Integer;
wParam: Integer;
lParam: Integer): Integer;
stdcall;
external 'user32.dll' name 'SendMessageA';
function capGetDriverDescriptionA(DrvIndex: Cardinal;
Name: PAnsiChar;
NameLen: Integer;
Description: PAnsiChar;
DescLen: Integer) : Boolean;
stdcall;
external 'avicap32.dll' name 'capGetDriverDescriptionA';
function capCreateCaptureWindowA(lpszWindowName: PAnsiChar;
dwStyle: Integer;
x : Integer;
y : Integer;
nWidth : Integer;
nHeight : Integer;
ParentWin: Integer;
nId: Integer): Integer;
stdcall;
external 'avicap32.dll' name 'capCreateCaptureWindowA';
function IntToStr(i: Integer): String;
begin
Str(i, Result);
end;
var
WebCamId : Integer;
CaptureWindow : Integer;
x : Integer;
FileName : PAnsiChar;
begin
WebcamId := 0;
CaptureWindow := capCreateCaptureWindowA('CaptureWindow', 0, 0, 0, 0, 0, 0, 0);
if CaptureWindow <> 0 then
begin
if SendMessageA(CaptureWindow, WM_CAP_DRIVER_CONNECT, WebCamId, 0) = 1 then
begin
for x := 1 to 20 do // Take 20 photos.
begin
SendMessageA(CaptureWindow, WM_CAP_GRAB_FRAME, 0, 0);
FileName := PAnsiChar('C:\Test' + IntToStr(x) + '.bmp');
SendMessageA(CaptureWindow, WM_CAP_SAVEDIB, 0, LongInt(FileName));
end;
end;
SendMessageA(CaptureWindow, WM_CAP_DRIVER_DISCONNECT, 0, 0);
end;
end.
I have successfully translated all of the apis using the ora_ffi package.
I am having trouble translating the below line from Pascal to PL/SQL (which saves the captured picture to a specified location identified by FileName).
SendMessageA(CaptureWindow, WM_CAP_SAVEDIB, 0, **LongInt**(FileName));
because I am unsure how to pass the FileName as a PLS_INTEGER (see bold for how I achieve this with pascal) which the SendMessageA definition requires. With pascal I can just cast the FileName to LongInt (does this return a pointer to the FileName? If so, I would like to emulate this casting with PL/SQL).
NOTE: The question is about how to convert Pascal to PL/SQL. The Pascal code works fine.
Any ideas?