I'm going to admit, right off the bat, that I'm Pascal-inexperienced, to say the least. So, any help I can get will be greatly appreciated. :)
As part of a larger program, I need to write a string variable to the clipboard. I've created a new project in Lazarus (version 1.0.12) so I can try to figure out how to do so without the complications caused by extra, unnecessary code, which I have included below:
program varToClipboard;
uses Clipbrd;
var
textToCopy:string;
begin
textToCopy := 'Test text from Pascal';
Clipboard.AsText := textToCopy;
end.
Using the above code, along with a required LCLBase
dependency, I'm getting the following error in CMD when running the compiled EXE:
An unhandled exception occurred at $000000000043D45E :
EAccessViolation : Access violation
$000000000043D45E CLIPBOARDREGISTERFORMAT, line 98 of ./include/lclintf.inc
$000000000043C35B PREDEFINEDCLIPBOARDFORMAT, line 185 of lclintf.pas
$0000000000415B0C TCLIPBOARD__SETASTEXT, line 452 of ./include/clipbrd.inc
$0000000000401802 main, line 12 of varToClipboard.lpr
According to the documentation, I seem to be doing everything right. Although, I have found the documentation to be... lacking on more than on occasion.
Also, what do I have to do so that I can run the compiled EXE (which will just generate and write a string to the clipboard) without the console window popping up?