ابتدا System.TypInfo را uses تعریف میکنیم به خاطر استفاده از GetObjectProp
حالا تابع زیر را تعریف میکنیم
procedure SetFontProperties(Control: TControl; Name: TFontName; Size: Integer; Styles: TFontStyles);
// Set font properties
var
Index: Integer;
Font: TFont;
AnObject: TObject;
ChildControl: TControl;
begin
// Set font properties
AnObject := GetObjectProp(Control, 'Font', nil);
if AnObject is TFont then
begin
// Set properties
Font := TFont(AnObject);
Font.Name := Name;
Font.Size := Size;
Font.Style := Styles;
end;
// Set child font properties
if Control is TWinControl then
begin
// Set
for Index := 0 to TWinControl(Control).ControlCount - 1 do
begin
// Child control
ChildControl := TWinControl(Control).Controls[Index];
// Set font properties
SetFontProperties(ChildControl, Name, Size, Styles);
end;
end;
end;و با کد زیر فراخوانی میکنیم
SetFontProperties(Self, 'Courier', 14, []);
برای ارسال پارامتر دو روش زیر وجود دارد
WinExec('C:\prog.exe param1 param2', SW_SHOW);یا
|
برای خواندن پارامترها از دستور زیر میتوان استفاده کرد
var i: integer;begin for i := 0 to ParamCount do ShowMessage(ParamStr(i));end;
یا
// execute with "MyProgram.exe param1 /param2"if FindCmdLineSwitch('param1') then ShowMessage('param1'); // will not be displayedif FindCmdLineSwitch('param2') then ShowMessage('param2'); // will be displayedif FindCmdLineSwitch('param3') then ShowMessage('param3'); // will not be displayed |
uses ComObj; ..
procdure startExcel;
var
oE:Variant;
begin
try
oE := GetActiveOleObject('Excel.Application');
except
oE := CreateOleObject('Excel.Application');
end;
oE.Workbooks.Open(filename, false, false);
oE.Visible := True;
end;
Declare @TableName Varchar(100)
Set @TableName = 'TableName'
Declare @Count int
Declare @SqlString Nvarchar(1000)
Set @SqlString = 'Select @OutCount = Count(*) From ' +@TableName
Exec sp_Executesql @SqlString, N'@OutCount Int Output', @OutCount = @Count Output