Wireless Communication Library Support Forum
Frameworks => Bluetooth Framework => Topic started by: luis on March 15, 2011, 12:43:34 PM
-
Good morning Mike,
I'm having doubts about his example vcl demo (IrDAOPPClientDemo.dpr). I managed to run your demo without any problems, but did not want to open a OpenDialog to fetch the file that I send to the destination device. I want to send directly, since I have my file in the c: \ file.txt.
His example is
TfmMain.btPutClick procedure (Sender: TObject);
var
Stream: TFileStream;
begin
then begin if OpenDialog.Execute
Stream: = TFileStream.Create (OpenDialog.FileName, or fmOpenRead fmShareDenyWrite);
wclShowError (wclOPPClient.Put (ExtractFileName (OpenDialog.FileName), Stream));
Stream.Free;
end;
end;
I wanted something so bad, but it's error OpenDialog obex but is operating normally:
if FileExists ('c:\file.txt') then begin
Stream: TFileStream.Create = ('c:\file.txt' or fmOpenRead fmShareDenyWrite);
wclShowError (wclOPPClient.Put (ExtractFileName ('c:\file.txt'), Stream));
Stream.Free;
end;
It's this error, if I put OpenDialog works, what am I doing wrong?
---------------------------
Error
---------------------------
OBEX session is not active.
---------------------------
OK
---------------------------
-
You didn't call wclOPPClienbt.OpenOBEX.
-
As I said, the obex was on but why the component works OpenDialog and if I pass the path to the file does not?
Thus the error yet, but if I change the path to OpenDialog work? Why?
if Error = WCL_E_SUCCESS then
begin
wclShowError(wclOPPClient.OpenOBEXSession);
//if OpenDialog.Execute then
if FileExists('c:\file.txt') then
begin
Stream := TFileStream.Create('c:\file.txt', fmOpenRead or fmShareDenyWrite);
{error}
wclShowError(wclOPPClient.Put(ExtractFileName('c:\file.txt'), Stream));
Stream.Free;
end
else
begin
wclShowError(wclOPPClient.CloseOBEXSession);
wclOPPClient.Disconnect;
end;
end;
-
It appears because OBEX session is not opened yet as WCL is async. library. You have to wait OnOBEXOpen event.