صفحه 4 از 6 اولاول ... 23456 آخرآخر
نمایش نتایج 121 تا 160 از 214

نام تاپیک: سورسهاي نمونه آموزشي

  1. #121
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي

    فانكشن ساخت فرم دايناميك :

    FUNCTION B_CreateForm(Var FName: TForm; FrmCaption: string;
    Const FrmAutoSize : Boolean = False;
    FrmBiDiMode : TBiDiMode = bdLeftToRight;
    FrmBorderIcons : TBorderIcons = [biSystemMenu, biMinimize, biMaximize];
    FrmBorderStyle : TFormBorderStyle = bsSizeable;
    FrmBorderWidth : TBorderWidth = 0;
    FrmClientHeight : Integer = -1;
    FrmClientWidth : Integer = -1;
    FrmColor : TColor = clBtnFace;
    FrmEnabled : Boolean = True;
    FrmFontCharset : TFontCharset = DEFAULT_CHARSET;
    FrmFontColor : TColor = clWindowText;
    FrmFontHeight : Integer = -11;
    FrmFontName : TFontName = 'Tahoma';
    FrmFontSize : Integer = 8;
    FrmFontStyle : TFontStyles = [];
    FrmFormStyle : TFormStyle = fsNormal;
    FrmHeight : Integer = -1;
    FrmHint : string = '';
    FrmKeyPreview : Boolean = False;
    FrmLeft : Integer = 0;
    FrmPopupMenu : TPopupMenu = nil;
    FrmPosition : TPosition = poDefaultPosOnly;
    FrmShowHint : Boolean = False;
    FrmTag : Integer = 0;
    FrmTop : Integer = 0;
    FrmVisible : Boolean = False;
    FrmWidth : Integer = -1;
    FrmWindowState : TWindowState = wsNormal;
    FrmTransparentColor : Boolean = False;
    FrmTransparentColorValue : TColor = clBlack;
    FrmPrintScale : TPrintScale = poProportional;
    FrmScaled : Boolean = True;
    FrmMarginsBottom : TMarginSize = 3;
    FrmMarginsLeft : TMarginSize = 3;
    FrmMarginsRight : TMarginSize = 3;
    FrmMarginsTop : TMarginSize = 3;
    FrmMenu : TMainMenu = nil;
    FrmPaddingBottom : TMarginSize = 0;
    FrmPaddingLeft : TMarginSize = 0;
    FrmPaddingRight : TMarginSize = 0;
    FrmPaddingTop : TMarginSize = 0;
    FrmParentBiDiMode : Boolean = True;
    FrmParentCustomHint : Boolean = True;
    FrmParentFont : Boolean = False;
    FrmPixelsPerInch : Integer = 96;
    FrmActiveControl : TWinControl = nil;
    FrmAlignWithMargins : Boolean = False;
    FrmAlphaBlend : Boolean = False;
    FrmAlphaBlendValue : Byte = 255;
    FrmAnchors : TAnchors = [akLeft, akTop];
    FrmAutoScroll : Boolean = False
    ): TForm;
    BEGIN
    FName := TForm.Create(nil);
    WITH FName DO
    BEGIN
    Caption := FrmCaption;
    AutoSize := FrmAutoSize;
    BiDiMode := FrmBiDiMode;
    BorderIcons := FrmBorderIcons;
    BorderStyle := FrmBorderStyle;
    BorderWidth := FrmBorderWidth;
    IF FrmClientHeight <> -1 THEN ClientHeight := FrmClientHeight;
    IF FrmClientWidth <> -1 THEN ClientWidth := FrmClientWidth;
    Color := FrmColor;
    Enabled := FrmEnabled;
    Font.Charset := FrmFontCharset;
    Font.Color := FrmFontColor;
    Font.Height := FrmFontHeight;
    Font.Name := FrmFontName;
    Font.Size := FrmFontSize;
    Font.Style := FrmFontStyle;
    FormStyle := FrmFormStyle;
    IF FrmHeight <> -1 THEN Height := FrmHeight;
    Hint := FrmHint;
    KeyPreview := FrmKeyPreview;
    Left := FrmLeft;
    PopupMenu := FrmPopupMenu;
    Position := FrmPosition;
    ShowHint := FrmShowHint;
    Tag := FrmTag;
    Top := FrmTop;
    Visible := FrmVisible;
    IF FrmWidth <> -1 THEN Width := FrmWidth;
    WindowState := FrmWindowState;
    TransparentColor := FrmTransparentColor;
    TransparentColorValue := FrmTransparentColorValue;
    PrintScale := FrmPrintScale;
    Scaled := FrmScaled;
    Margins.Bottom := FrmMarginsBottom;
    Margins.Left := FrmMarginsLeft;
    Margins.Right := FrmMarginsRight;
    Margins.Top := FrmMarginsTop;
    Menu := FrmMenu;
    Padding.Bottom := FrmPaddingBottom;
    Padding.Left := FrmPaddingLeft;
    Padding.Right := FrmPaddingRight;
    Padding.Top := FrmPaddingTop;
    ParentBiDiMode := FrmParentBiDiMode;
    ParentCustomHint := FrmParentCustomHint;
    ParentFont := FrmParentFont;
    PixelsPerInch := FrmPixelsPerInch;
    ActiveControl := FrmActiveControl;
    AlignWithMargins := FrmAlignWithMargins;
    AlphaBlend := FrmAlphaBlend;
    AlphaBlendValue := FrmAlphaBlendValue;
    Anchors := FrmAnchors;
    AutoScroll := FrmAutoScroll
    END;
    Result := FName;
    END;




    var
    FSyntax: TForm;
    begin
    TRY
    FSyntax := B_CreateForm(FSyntax, 'FSyntax');
    FSyntax.ShowModal;
    FINALLY
    FSyntax.Free;
    END;




    FSyntax := B_CreateForm(FSyntax, 'FSyntax', False, bdLeftToRight, [biSystemMenu, biMinimize, biMaximize], bsSizeable, 0, -1, -1, clBtnFace, True, DEFAULT_CHARSET, clWindowText,
    -11, 'Tahoma', 8, [], fsNormal, -1, '', False, 0, nil, poDefaultPosOnly, False, 0, 0, False, -1, wsNormal, False, clBlack, poProportional, True,
    3, 3, 3, 3, nil, 0, 0, 0, 0, True, True, False, 96, nil, False, False, 255, [akLeft, akTop], False);



    FSyntax := B_CreateForm(FSyntax,
    {Caption}'FSyntax',
    {AutoSize}False,
    {BiDiMode}bdLeftToRight,
    {BorderIcons}[biSystemMenu, biMinimize, biMaximize], {BorderStyle}bsSizeable,
    {BorderWidth}0,
    {ClientHeight}662, {ClientWidth}929,
    {Color}clBtnFace,
    {Enabled}True,
    {Font.Charset}DEFAULT_CHARSET, {Font.Color}clWindowText, {Font.Height}-11, {Font.Name}'Tahoma', {Font.Size}8, {Font.Style}[],
    {FormStyle}fsNormal,
    {Height}-1, {Hint}'',
    {KeyPreview}False,
    {Left}0, {PopupMenu}nil,
    {Position}poDesktopCenter,
    {ShowHint}False,
    {Tag}0, {Top}0,
    {Visible}False,
    {Width}-1,
    {WindowState}wsNormal,
    {TransparentColor}False, {TransparentColorValue}clBlack,
    {PrintScale}poProportional,
    {Scaled}True,
    {Margins.Bottom}3, {Margins.Left}3, {Margins.Right}3, {Margins.Top}3,
    {Menu}nil,
    {Padding.Bottom}0, {Padding.Left}0, {Padding.Right}0, {Padding.Top}0,
    {ParentBiDiMode}True, {ParentCustomHint}True, {ParentFont}False,
    {PixelsPerInch}96,
    {ActiveControl}nil,
    {AlignWithMargins}False,
    {AlphaBlend}False, {AlphaBlendValue}255,
    {Anchors}[akLeft, akTop],
    {AutoScroll}False
    );



    اگه ممكنه دوستان در بهبود ابن فانكشن كمك كنند
    شايد كلاً راه غلطي باشه
    ممنون
    آخرین ویرایش به وسیله SayeyeZohor : جمعه 23 فروردین 1392 در 15:55 عصر

  2. #122

    نقل قول: سورسهاي نمونه آموزشي

    سلام
    اگه ممكنه دوستان در بهبود ابن فانكشن كمك كنند
    شايد كلاً راه غلطي باشه
    اگه بخواهم تابعی برای این کار طراحی کنم یک رکورد خاص تعریف می کنم که کاربر مشخصات را در نمونه ای از آن رکورد تنظیم کند و تابعی که نوشتی رو طوری می نوشتم که به جای این همه پارامتر مختلف فق یک پارامتر دریافت کنه که اون هم از نوی رکوردی که گفتم باشه تا این همه شلوغ کاری نشه و قابل فهم تر باشه. توی اون تابعی که نوشتی اگر ما بخواهیم فقط پارامتر X ام را تغییر دهیم باید به پارامتر های قبلی هم مقدار بدهیم که این مورد کمی کار رو سخت می کنه(البته در زبانی مثل VB این مشکل وجود ندارد). چنین مشکلی با راه حلی که پیشنهاد کردم کاملاً قابل حل است.
    موفق باشید...

  3. #123
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي


    Type
    TPropertyOfForm = Record
    FName : TForm;
    FrmCaption : string;
    FrmAutoSize : Boolean;
    FrmBiDiMode : TBiDiMode;
    FrmBorderIcons : TBorderIcons;
    FrmBorderStyle : TFormBorderStyle;
    FrmBorderWidth : TBorderWidth;
    FrmClientHeight : Integer;
    FrmClientWidth : Integer;
    FrmColor : TColor;
    FrmEnabled : Boolean;
    FrmFontCharset : TFontCharset;
    FrmFontColor : TColor;
    FrmFontHeight : Integer;
    FrmFontName : TFontName;
    FrmFontSize : Integer;
    FrmFontStyle : TFontStyles;
    FrmFormStyle : TFormStyle;
    FrmHeight : Integer;
    FrmHint : string;
    FrmKeyPreview : Boolean;
    FrmLeft : Integer;
    FrmPopupMenu : TPopupMenu;
    FrmPosition : TPosition;
    FrmShowHint : Boolean;
    FrmTag : Integer;
    FrmTop : Integer;
    FrmVisible : Boolean;
    FrmWidth : Integer;
    FrmWindowState : TWindowState;
    FrmTransparentColor : Boolean;
    FrmTransparentColorValue : TColor;
    FrmPrintScale : TPrintScale;
    FrmScaled : Boolean;
    FrmMarginsBottom : TMarginSize;
    FrmMarginsLeft : TMarginSize;
    FrmMarginsRight : TMarginSize;
    FrmMarginsTop : TMarginSize;
    FrmMenu : TMainMenu;
    FrmPaddingBottom : TMarginSize;
    FrmPaddingLeft : TMarginSize;
    FrmPaddingRight : TMarginSize;
    FrmPaddingTop : TMarginSize;
    FrmParentBiDiMode : Boolean;
    FrmParentCustomHint : Boolean;
    FrmParentFont : Boolean;
    FrmPixelsPerInch : Integer;
    FrmActiveControl : TWinControl;
    FrmAlignWithMargins : Boolean;
    FrmAlphaBlend : Boolean;
    FrmAlphaBlendValue : Byte;
    FrmAnchors : TAnchors;
    FrmAutoScroll : Boolean;
    end;

  4. #124
    کاربر دائمی آواتار Ananas
    تاریخ عضویت
    آبان 1390
    محل زندگی
    طول 50 و عرض 34 درجه
    سن
    36
    پست
    894

    نقل قول: سورسهاي نمونه آموزشي

    یک تابع هم برای مقدار دهی پیش فرض رکورد تعریف کنید که اول همه ی پارامتر ها رو پر کنه بعد اگه کاربر خواست قسمتیش رو تغییر بده بعد بفرسته به تابع.
    البته نظر کلی من در مورد تعریف همچین تابعی اینه که : چه کاریه! به جای این کار یک تابع تعریف کنید که فرم رو با مقدار دهی اولیه بسازه و بعد اگه کاربر خواست قسمتیش رو تغییر میده.
    امر فرمودن مثال بزنم، چشم:

    procedure TForm1.Button1Click(Sender: TObject);
    var
    f : TForm;
    b : TButton;
    begin
    f := TForm.Create(nil);
    f.Color := $00808000;
    f.Caption := 'مای فرم';
    f.BorderStyle := bsSizeToolWin;
    b := TButton.Create(f);
    b.Parent := f;
    b.Caption := 'مای باتن';
    f.ShowModal;
    f.Free;
    end;

    اصلا نیازی به تابع هم نیست ولی میتونه اینطور باشه:

    function CreateFreeForm(AOwner: TComponent):TForm;
    begin
    Result := TForm.Create(AOwner);
    end;
    آخرین ویرایش به وسیله Ananas : یک شنبه 25 فروردین 1392 در 15:36 عصر

  5. #125
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

  6. #126
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي

    استخراج آيكن يك فايل اجرايي و قراردادن آن در ImageList :


    Uses CommCtrl




    procedure ExtractIconFileToImageList(ImageList: TImageList; const Filename: string);
    var
    FileInfo: TShFileInfo;
    begin
    if FileExists(Filename) then
    begin
    FillChar(FileInfo, SizeOf(FileInfo), 0);
    SHGetFileInfo(PChar(Filename), 0, FileInfo, SizeOf(FileInfo), SHGFI_ICON or SHGFI_SMALLICON);
    if FileInfo.hIcon <> 0 then
    begin
    ImageList_AddIcon(ImageList.Handle, FileInfo.hIcon);
    DestroyIcon(FileInfo.hIcon);
    end;
    end;
    end;
    آخرین ویرایش به وسیله SayeyeZohor : یک شنبه 25 فروردین 1392 در 17:06 عصر

  7. #127
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي

    تشخيص نصب بودن نسخه هاي دلفي و نسخه هاي دات نت فريمورك :

    مرحله اول:

    unit SelectDelphiVersion;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, ImgList, ComCtrls, Vcl.ExtCtrls;

    type
    TFrmSelDelphiVer = class(TForm)
    Label1: TLabel;
    ImageList1: TImageList;
    ListViewIDEs: TListView;
    Panel1: TPanel;
    ButtonOk: TButton;
    ButtonCancel: TButton;
    private
    { Private declarations }
    public
    { Public declarations }
    procedure LoadDelphiInstalledVersions;
    procedure LoadNetFrameworkInstalledVersions;
    end;


    implementation
    {$R *.dfm}

    uses
    Registry, CommCtrl, ShellAPI;

    type
    TDelphiVersions =
    (
    Delphi4,
    Delphi5,
    Delphi6,
    Delphi7,
    Delphi8,
    Delphi2005,
    Delphi2006,
    Delphi2007,
    Delphi2009,
    Delphi2010,
    DelphiXE,
    DelphiXE2,
    DelphiXE3
    );

    const
    DelphiVersionsNames: array[TDelphiVersions] of string = (
    'Delphi 4',
    'Delphi 5',
    'Delphi 6',
    'Delphi 7',
    'Delphi 8',
    'BDS 2005',
    'BDS 2006',
    'RAD Studio 2007',
    'RAD Studio 2009',
    'RAD Studio 2010',
    'RAD Studio XE',
    'RAD Studio XE2',
    'RAD Studio XE3'
    );

    DelphiRegPaths: array[TDelphiVersions] of string = (
    '\Software\Borland\Delphi\4.0',
    '\Software\Borland\Delphi\5.0',
    '\Software\Borland\Delphi\6.0',
    '\Software\Borland\Delphi\7.0',
    '\Software\Borland\BDS\2.0',
    '\Software\Borland\BDS\3.0',
    '\Software\Borland\BDS\4.0',
    '\Software\Borland\BDS\5.0',
    '\Software\CodeGear\BDS\6.0',
    '\Software\CodeGear\BDS\7.0',
    '\Software\Embarcadero\BDS\8.0',
    '\Software\Embarcadero\BDS\9.0',
    '\Software\Embarcadero\BDS\10.0'
    );





    type
    TNetFrameworkVersions =
    (
    NetFramework1_0,
    NetFramework1_1,
    NetFramework2_0,
    NetFramework3_0,
    NetFramework3_5,
    NetFramework4,
    NetFramework4_0
    );

    const
    NetFrameworkVersionsNames: array[TNetFrameworkVersions] of string = (
    '.NetFramework v1.0',
    '.NetFramework v1.1.4322',
    '.NetFramework v2.0.50727',
    '.NetFramework v3.0',
    '.NetFramework v3.5',
    '.NetFramework v4',
    '.NetFramework v4.0'
    );

    NetFrameworkRegPaths: array[TNetFrameworkVersions] of string = (
    '\SOFTWARE\Microsoft\.NETFramework\policy\v1.0',
    '\SOFTWARE\Microsoft\NET Framework Setup\NDP\v1.1.4322',
    '\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727',
    '\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0',
    '\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5',
    '\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4',
    '\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4.0'
    );


    function RegKeyExists(const RegPath: string;const RootKey :HKEY): Boolean;
    var
    Reg: TRegistry;
    begin
    try
    Reg := TRegistry.Create;
    try
    Reg.RootKey := RootKey;
    Result := Reg.KeyExists(RegPath);
    finally
    Reg.Free;
    end;
    except
    Result := False;
    end;
    end;
    function RegReadStr(const RegPath, RegValue: string; var Str: string; const RootKey :HKEY): Boolean;
    var
    Reg: TRegistry;
    begin
    try
    Reg := TRegistry.Create;
    try
    Reg.RootKey := RootKey;
    Result := Reg.OpenKey(RegPath, True);
    if Result then Str := Reg.ReadString(RegValue);
    finally
    Reg.Free;
    end;
    except
    Result := False;
    end;
    end;
    procedure ExtractIconFileToImageList(ImageList: TImageList; const Filename: string);
    var
    FileInfo: TShFileInfo;
    begin
    if FileExists(Filename) then
    begin
    FillChar(FileInfo, SizeOf(FileInfo), 0);
    SHGetFileInfo(PChar(Filename), 0, FileInfo, SizeOf(FileInfo), SHGFI_ICON or SHGFI_SMALLICON);
    if FileInfo.hIcon <> 0 then
    begin
    ImageList_AddIcon(ImageList.Handle, FileInfo.hIcon);
    DestroyIcon(FileInfo.hIcon);
    end;
    end;
    end;



    { TFrmSelDelphiVer }
    procedure TFrmSelDelphiVer.LoadDelphiInstalledVersions;
    Var
    item : TListItem;
    DelphiComp : TDelphiVersions;
    FileName : string;
    ImageIndex : Integer;
    begin
    for DelphiComp := Low(TDelphiVersions) to High(TDelphiVersions) do
    begin
    if RegKeyExists(DelphiRegPaths[DelphiComp], HKEY_CURRENT_USER) then
    begin
    if RegReadStr(DelphiRegPaths[DelphiComp], 'App', FileName, HKEY_CURRENT_USER) and FileExists(FileName) then
    begin
    item := ListViewIDEs.Items.Add;
    item.Caption := DelphiVersionsNames[DelphiComp];
    item.SubItems.Add(FileName);
    ExtractIconFileToImageList(ImageList1, Filename);
    ImageIndex := ImageList1.Count - 1;
    item.ImageIndex := ImageIndex;
    end;
    end;
    end;
    end;


    procedure TFrmSelDelphiVer.LoadNetFrameworkInstalledVersions ;
    Var
    item : TListItem;
    NetFrameworkComp : TNetFrameworkVersions;
    FileName : string;
    ImageIndex : Integer;
    begin
    for NetFrameworkComp := Low(TNetFrameworkVersions) to High(TNetFrameworkVersions) do
    begin
    if RegKeyExists(NetFrameworkRegPaths[NetFrameworkComp], HKEY_LOCAL_MACHINE) then
    begin
    if RegReadStr(NetFrameworkRegPaths[NetFrameworkComp], 'InstallPath', FileName, HKEY_LOCAL_MACHINE) {and FileExists(FileName)} then
    begin
    item := ListViewIDEs.Items.Add;
    item.Caption := NetFrameworkVersionsNames[NetFrameworkComp];
    item.SubItems.Add(FileName);
    ExtractIconFileToImageList(ImageList1, Filename);
    ImageIndex := ImageList1.Count - 1;
    item.ImageIndex := ImageIndex;
    end;
    end;
    end;
    end;

    end.

  8. #128
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي

    مرحله يا فرم دوم :

    unit UnitTest;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls;

    type
    TForm9 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;

    var
    Form9: TForm9;

    implementation

    uses
    ComCtrls,
    SelectDelphiVersion;

    {$R *.dfm}

    procedure TForm9.Button1Click(Sender: TObject);
    var
    Frm : TFrmSelDelphiVer;
    item : TListItem;
    DelphiPath : string;
    begin
    Frm := TFrmSelDelphiVer.Create(Self);
    try
    Frm.LoadDelphiInstalledVersions;
    if Frm.ListViewIDEs.Items.Count=0 then
    ShowMessage('Delphi is not installed in this system')
    else
    if Frm.ShowModal = mrOk then
    begin
    item:=Frm.ListViewIDEs.Selected;
    if Assigned(item) then
    begin
    DelphiPath :=ExtractFilePath(item.SubItems[0]);
    ShowMessage(DelphiPath);
    end;
    end;
    finally
    Frm.Free;
    end;
    end;



    procedure TForm9.Button2Click(Sender: TObject);
    var
    Frm : TFrmSelDelphiVer;
    item : TListItem;
    NetFrameworkiPath : string;
    begin
    Frm := TFrmSelDelphiVer.Create(Self);
    try
    Frm.LoadNetFrameworkInstalledVersions;
    if Frm.ListViewIDEs.Items.Count = 0 then
    ShowMessage('NetFramework is not installed in this system')
    else
    if Frm.ShowModal = mrOk then
    begin
    item := Frm.ListViewIDEs.Selected;
    if Assigned(item) then
    begin
    NetFrameworkiPath := ExtractFilePath(item.SubItems[0]);
    ShowMessage(NetFrameworkiPath);
    end;
    end;
    finally
    Frm.Free;
    end;
    end;

    end.

  9. #129
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي


    uses
    ShellApi;

    function CopyDir(const fromDir, toDir: string): Boolean;
    var
    fos: TSHFileOpStruct;
    begin
    ZeroMemory(@fos, SizeOf(fos));
    with fos do
    begin
    wFunc := FO_COPY;
    fFlags := FOF_FILESONLY;
    pFrom := PChar(fromDir + #0);
    pTo := PChar(toDir)
    end;
    Result := (0 = ShFileOperation(fos));
    end;


    function MoveDir(const fromDir, toDir: string): Boolean;
    var
    fos: TSHFileOpStruct;
    begin
    ZeroMemory(@fos, SizeOf(fos));
    with fos do
    begin
    wFunc := FO_MOVE;
    fFlags := FOF_FILESONLY;
    pFrom := PChar(fromDir + #0);
    pTo := PChar(toDir)
    end;
    Result := (0 = ShFileOperation(fos));
    end;

    function DelDir(dir: string): Boolean;
    var
    fos: TSHFileOpStruct;
    begin
    ZeroMemory(@fos, SizeOf(fos));
    with fos do
    begin
    wFunc := FO_DELETE;
    fFlags := FOF_SILENT or FOF_NOCONFIRMATION;
    pFrom := PChar(dir + #0);
    end;
    Result := (0 = ShFileOperation(fos));
    end;


    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if cCopyDir('d:\download', 'e:\') = True then
    ShowMessage('Directory copied.');
    end;

  10. #130

    بدست آودن Traffic مصرفی در شبکه !

    درود
    در زمان قدیم من در بخش برنامه نویسی شبکه تاپیکی ایجاد کردم (الان حذف شده)و بعد از من هم کسانی بودن که تواپیکی با همون موضوع (بدست آودن Traffic مصرفی در شبکه) ایجاد کردن ، احتمالاً به نتیجه هم رسیدن ولی روشهایی که ارائه شده کمی برای تازه کارها مشکل سازه به همین خاطر تصمیم گرفتم برنامه ای رو در زمینه برای شما قرار بدم تا حالشو ببرید.

    اینم عکس از اجرای برنامه :
    NetState.jpg
    موفق باشید.
    فایل های ضمیمه فایل های ضمیمه
    Everything that has a beginning has an end. ... The End?



  11. #131

    نقل قول: بدست آودن Traffic مصرفی در شبکه !

    درود
    در زمان قدیم من در بخش برنامه نویسی شبکه تاپیکی ایجاد کردم (الان حذف شده)و بعد از من هم کسانی بودن که تواپیکی با همون موضوع (بدست آودن Traffic مصرفی در شبکه) ایجاد کردن ، احتمالاً به نتیجه هم رسیدن ولی روشهایی که ارائه شده کمی برای تازه کارها مشکل سازه به همین خاطر تصمیم گرفتم برنامه ای رو در زمینه برای شما قرار بدم تا حالشو ببرید.

    اینم عکس از اجرای برنامه :
    NetState.jpg
    موفق باشید.
    خوبه ولي Send و Recive رو يكي نشون ميده !
    آخرین ویرایش به وسیله بهروز عباسی : یک شنبه 13 اردیبهشت 1394 در 11:31 صبح

  12. #132
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    RunAsAdmin


    uses
    WinSvc;

    function IsAdmin(Host : string = '') : Boolean;
    var
    H: SC_HANDLE;
    begin
    if Win32Platform <> VER_PLATFORM_WIN32_NT then
    Result := True
    else begin
    H := OpenSCManager(PChar(Host), nil, GENERIC_READ or GENERIC_WRITE or GENERIC_EXECUTE);
    Result := H <> 0;
    if Result then
    CloseServiceHandle(H);
    end;
    end;





    function IsRunningWithAdminPrivs: Boolean;
    begin
    var
    List: TStringList;
    begin
    List := TStringList.Create;
    try
    try
    List.Text := 'Sample';
    // Use SHGetFolder path to retreive the program files folder
    // here is hardcoded for the sake of the example
    List.SaveToFile('C:\program files\test.txt');
    Result := True;
    except
    Result := False;
    end;
    finally
    List.Free;
    DeleteFile('C:\program files\test.txt');
    end;
    end;

  13. #133
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    RunAsAdmin

    procedure RunAsAdmin(const aFile: string; const aParameters: string = ''; Handle: HWND = 0);
    var
    sei: TShellExecuteInfo;
    begin
    FillChar(sei, SizeOf(sei), 0);

    sei.cbSize := SizeOf(sei);
    sei.Wnd := Handle;
    sei.fMask := SEE_MASK_FLAG_DDEWAIT or SEE_MASK_FLAG_NO_UI;
    sei.lpVerb := 'runas';
    sei.lpFile := PChar(aFile);
    sei.lpParameters := PChar(aParameters);
    sei.nShow := SW_SHOWNORMAL;

    if not ShellExecuteEx(@sei) then
    RaiseLastOSError;
    end;

  14. #134

  15. #135
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي


    unit CollapsePanel;

    {************************************************* ***************************
    COLLAPSE PANEL ver 1.11 - Copyright (c) Lindsay D'Penha

    Disclaimer: This component is freeware so I take no responsibility for any problems or losses that may occur, use at your own risk

    This component is freeware, but if you modify anything send me the changes. If you modify the
    compenent you may then include your copyright along with the original one.
    You are free to distribute this component provided this readme file is not modified or removed from the distribution.
    This component cannot be used in a commercial application without my written approval.
    i.e. you cannot include this component in an application that you are making money from, without my approval.

    Programmer: Lindsay D'Penha
    Date Created: 01/10/2001
    Date Modified: 01/18/2001

    Collapse Panel is a simple drop down panel component.
    It has a header and a button to allow it to expand and collapse.

    Main Properties
    ****************
    HeaderCaption Set the Headers Caption
    AutoClose If True then it will autoclose AutoCloseTime millisecs after the mouse is out of the panel default is false
    AutoCloseTime Sets the time after which the the panle will close default is 1500

    If Auto Close is true then the collapse button acts as a stay on top button
    ************************************************** ***************************}

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,Buttons,
    ExtCtrls;

    const
    cCloseUpGovernor = 300; // when the panel reaches this limit, the animation redraws less frequently


    type
    TCollapsePanel = class(TPanel)
    private
    { Private declarations }
    FExpandedHeight:Integer;
    FCloseUpTimer:TTimer;
    FAutoCloseTime:Integer;
    FAbout:String;
    IsCollapsed:Boolean;
    StayOpen:Boolean;
    FAutoClose:Boolean;
    function ApplyDark(Color: TColor; HowMuch: Byte): TColor;
    Procedure PullDown;
    Procedure CloseUp;
    procedure CloseUpTimerTimer(Sender: TObject);
    procedure SetAutoCloseTime(Value:Integer);
    procedure CMMouseEnter(var Msg: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;
    procedure OnAutoClose(AutoClose:Boolean);
    procedure SetAbout(value:String);
    procedure setCollapse(value: boolean);
    protected
    { Protected declarations }
    HeaderPanel:TPanel;
    Collapser:TSpeedButton;
    function GetHeaderCaption:TCaption;
    procedure SetHeaderCaption(Value:TCaption);
    public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    procedure CollapserClick(Sender: TObject);
    Procedure Paint; override;
    published
    { Published declarations }
    property HeaderCaption:TCaption read GetHeaderCaption write SetHeaderCaption;
    property AutoClose:Boolean read FAutoClose write OnAutoClose default False;
    property AutoCloseTime:Integer read FAutoCloseTime write SetAutoCloseTime default 1500;
    property Collapsed:Boolean read IsCollapsed write setCollapse default False;
    property About:String read FAbout Write SetAbout;
    end;

    procedure Register;

    implementation

    procedure Register;
    begin
    RegisterComponents('LDComp', [TCollapsePanel]);
    end;

    { TCollapsePanel }

    constructor TCollapsePanel.Create(AOwner: TComponent);
    begin
    inherited Create(AOwner);
    FAbout:= '(C) Lindsay DPenha (iamlinz@hotmail.com)';

    Caption:='';
    HeaderPanel:=TPanel.Create(self);
    HeaderPanel.Parent:= self;
    HeaderPanel.Align:= alTop;
    HeaderPanel.Height:= 16;
    HeaderPanel.Color:= ApplyDark(Color,100);
    HeaderPanel.ParentFont:=True;

    FCloseUpTimer:=TTimer.create(self);
    FCloseUpTimer.Enabled:=False;
    FAutoCloseTime:=1500;
    FCloseUpTimer.Interval:=FAutoCloseTime;


    Collapser:=TSpeedButton.create(self);
    Collapser.Parent:=HeaderPanel;
    Collapser.Font.Name:='Courier';
    Collapser.Font.Size:=10;
    Collapser.Font.Style:=[fsBold];
    Collapser.Height:=15;
    Collapser.Width:=15;
    Collapser.Top:= 0;
    Collapser.Left:= 0;
    Collapser.Caption:='-';
    Collapser.Flat:=True;



    Collapser.OnClick:= CollapserClick;
    FCloseUpTimer.OnTimer:= CloseUpTimerTimer;
    FExpandedHeight:=Height;

    IsCollapsed:=False;
    Collapsed:=False;
    StayOpen:=False;
    AutoClose:=False;

    Caption:= '';
    end;


    procedure TCollapsePanel.setCollapse(value:boolean);
    begin
    if value<>IsCollapsed then
    begin
    if value then
    CloseUp
    else
    PullDown;
    end;
    end;

    procedure TCollapsePanel.CollapserClick(Sender: TObject);
    begin
    if FAutoClose then
    StayOpen:=Collapser.Down
    else
    begin
    if IsCollapsed then
    PullDown
    else
    CloseUp;
    end;
    end;

    Function TCollapsePanel.ApplyDark(Color:TColor; HowMuch:Byte):TColor;
    Var r,g,b:Byte;
    Begin
    Color:=ColorToRGB(Color);
    r:=GetRValue(Color);
    g:=GetGValue(Color);
    b:=GetBValue(Color);
    if r>HowMuch then r:=r-HowMuch else r:=0;
    if g>HowMuch then g:=g-HowMuch else g:=0;
    if b>HowMuch then b:=b-HowMuch else b:=0;
    result:=RGB(r,g,b);
    End;

    procedure TCollapsePanel.Paint;
    begin
    inherited;
    HeaderPanel.Color:= ApplyDark(Color,20);
    end;

    function TCollapsePanel.GetHeaderCaption: TCaption;
    begin
    with HeaderPanel do
    begin
    result:= HeaderPanel.Caption;
    end;
    end;

    procedure TCollapsePanel.SetHeaderCaption(Value: TCaption);
    begin
    with HeaderPanel do
    begin
    if Value<>Caption then
    Caption:=Value;
    end;
    end;

    procedure TCollapsePanel.CMMouseEnter(var Msg: TMessage);
    begin
    if FAutoClose then
    begin
    FCloseUpTimer.Enabled:=False;
    if IsCollapsed then PullDown;
    end;
    end;

    procedure TCollapsePanel.CMMouseLeave(var Msg: TMessage);
    begin
    if FAutoClose = False then exit;
    if IsCollapsed then exit;
    if StayOpen then exit;
    FCloseUpTimer.Enabled:=True;
    end;

    procedure TCollapsePanel.CloseUp;
    var I:Integer;
    begin
    if not IsCollapsed then
    begin
    IsCollapsed:=True;
    FExpandedHeight:=Height;
    for I:= FExpandedHeight downto (HeaderPanel.Height+1) do // Simple Scrolling effect
    begin
    if FExpandedHeight < cCloseUpGovernor then
    Height:=I
    else if(I mod 4)=0 then
    begin
    Height:=I;
    end;
    end;
    Height:=HeaderPanel.Height+1;
    Collapser.Caption:='+';
    end;
    invalidate;
    end;

    procedure TCollapsePanel.PullDown;
    var I:Integer;
    begin
    if IsCollapsed then
    begin
    IsCollapsed:=False;
    for I:= (HeaderPanel.Height+1) to FExpandedHeight do // Simple logic for Scrolling effect, with diff accelerations
    begin
    if FExpandedHeight < 300 then
    Height:=I
    else if (I mod 4)=0 then // if height larger than 300 then write to screen only when mod =0 is true, works like a step it in the for loop
    Height:=I;
    end;
    Height:= FExpandedHeight; // if the mod didnt get to the final value
    Collapser.Caption:='-';
    end;
    invalidate;
    end;

    procedure TCollapsePanel.CloseUpTimerTimer;
    begin
    CloseUp;
    FCloseUpTimer.Enabled:=False;
    end;

    procedure TCollapsePanel.OnAutoClose(AutoClose: Boolean);
    begin
    if FAutoClose<>AutoClose then
    FAutoClose:= AutoClose;

    if AutoClose then
    begin
    Collapser.GroupIndex:= -1;
    Collapser.AllowAllUp:=True;
    end
    else
    begin
    Collapser.GroupIndex:=0;
    Collapser.AllowAllUp:=False;
    end;
    end;


    procedure TCollapsePanel.SetAutoCloseTime(Value: Integer);
    begin
    FAutoCloseTime:=Value;
    FCloseUpTimer.Interval:=FAutoCloseTime;
    end;


    procedure TCollapsePanel.SetAbout(value: String);
    begin
    FAbout:= '(C) Lindsay DPenha (iamlinz@hotmail.com)';
    end;

    end.

  16. #136
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي

    Download images from the internet to a stream



    uses wininet ;

    function LoadImage ( url: string ): TMemoryStream;
    var
    hInternet, hConnect: pointer;
    dwBytesRead, i, L: cardinal;
    sTemp: AnsiString;
    begin
    Result: = TMemoryStream.Create;
    HINTERNET: InternetOpen = ( 'MyApp' , INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0 );
    try
    if Assigned (HINTERNET) then
    begin
    hConnect: = InternetOpenUrl (hInternet, PChar (url), nil, 0 , 0 , 0 );
    if Assigned (hConnect) then
    try
    I: = 1 ;
    repeat
    SetLength (sTemp, L + i);
    if not InternetReadFile (hConnect, @ sTemp , sizeof (L), dwBytesRead) then
    Break ;
    inc (i, dwBytesRead);
    until dwBytesRead = 0 ;
    finally
    InternetCloseHandle (hConnect);
    end;
    end;
    finally
    InternetCloseHandle (hInternet);
    end;
    Result.Write (sTemp [ 1 ], Length (sTemp));
    Result.Position: = 0 ;
    end;

  17. #137
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي

    This function is used to download images from a variety of formats: BMP , gif , png , jpeg , tiff , ico , etc. no problem. The main thing you need to do is save images with the same extensions that they were then to avoid confusion. I kept the names of the files that are taking direct links to pictures. To get the name of the file Url use function

    function  ExtractUrlFileName ( const AURL: string ): string; 
    var
    I: Integer;
    begin
    I: = LastDelimiter ('/', AURL);
    Result: = Copy (AURL, I + 1, Length (AUrl) - (i));
    end;

  18. #138
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي

    The module main window Minesweeper 2002



    unit saper_l;
    interface
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
    Dialogs, Menus, StdCtrls, OleCtrls, HHOPENLib_TLB;
    type
    TForm1 = class(TForm)
    MainMenul: TMainMemi;
    N1: TMemiltem;
    N2: TMemiltem;
    N3: TMenuItem;
    N4: TMenuItem;
    Hhopen1: THhopen;
    procedure FormlCreate(Sender: TObject);
    procedure FormlPaint(3ender; TObject);
    procedure FomlMouseDovmf Sender: TObject; Button: TMouseButton,-
    Shift: TShiftState( X, Y: Integer);
    procedure NIClick(Sender: TObject);
    procedure K4Click(Sender: TObject);
    procedure N3Click(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;
    var
    Form1: TForml;
    implementation
    uses saper_2;
    {$R*.DFM}
    const
    MR = 10; // кол-во клеток по вертикали
    МС = 10; // кол-во клеток по горизонтали
    NМ = 10; // кол-во мин
    W = 40; // ширина клетки поля
    Н = 40; // аысога клетки поля
    var
    pole: array(0..MR+1, 0.. MC+1] of integer; // минное попе
    // значение элемента массива:
    // 0..8 — количество мин в соседний клетках
    // 9 — в клетке мина
    // 100,.109 — клетка открыта
    // 200..209 — в клетку поставлен флаг
    nMin : integer; // кол-во найденных мин
    nFlag : integer; // кол-во поставленных флагов
    status : integer; //0 — начало игры; I - игра; 2 - результат
    Procedure NewGameO; forward; // генерирует новое поле
    Procedure ShowPole(Canvas : TCanvas; status : integer); forward;
    //Показывает поле
    Procedure Kletka(Canvas : TCanvas; row, col, status ; integer); forward;
    // выводит содержимое клетки
    Procedure Open(row, col : integer); forward;// открывает текущую и все соседние клетки, в которых нет мин
    Procedure MinafCanvas : TCanvas; х, у : integer); forward; // рисует мину
    Procedure Flag(Canvas : TCanvas; x, у : integer); forward;// рисует флаг
    // выводит на экран содержимое клетки
    Procedure Kletka(Canvas : TCanvas; row, col, status : integer);
    var
    х,у : integer; // коорлинаты области вывода
    begin
    х := (col-1)* W + 1;
    у := (row-1)* H + 1;
    if status = 0 then
    begin
    Canvas.Brush.Color := clLtGray;
    Canvas,Rectangle(x-1,y-1,x+W,y+H);
    exit;
    end;
    if Pole[row,col] < 100 then
    begin
    Canvas.Brush.Color := clLtGray; // неоткрытые — серые
    Canvas.Rectangle(x-1,y-1,x+W,у+Н);
    // есл Hipa завершена (status = 2), то показать мины
    if (status = 2| and (Pole[row,col] = 9)
    then Mina(Canvas, x, y);
    exit;
    end;
    // открываем клетку
    Canvas.Brush.Color := clWhite; // открытые белые
    Canvas.Rectangle(x-1,y-1,x+W,y+H);
    if (Pole trow,col] = 100)
    then exit; // клетка открыта, но она пустая
    if (Pole[row,col] >= 101) and (Pole[row,col] <= 108) then
    begin
    Canvas.Font.Size := 14;
    Canvas.Font.Color := clBlue;
    Canvas.TextOut(x+3,y+2,IntToStr(Pole[row,col] -1001);
    exit;
    end;
    if (Pole[row,colj >= 200) then
    Flag(Canvas, x, y);
    if (Pole[row,col] = 109) then // на этой мине подорвались!
    begin
    Canvas.Brush.Color := clRed;
    Canvas.Rectangle(x-1,y-1,x+W,y+H);
    end;
    if ((Pole[row,col] mod 10) = 9) and (status = 2) then
    Mina(Canvas, x, y);
    end;
    // показывает поле
    Procedure ShowPole(Canvas ; TCanvas; status : integer);
    var
    row,col : integer;
    begin
    for row := 1 to MR do
    for col := 1 to MC do
    Kletka(Canvas, row, col, status);
    end;
    // рекурсивная функция открывает текущую и все соседние
    // клетки, в которых нет мин
    Procedure Open(row, col : integer);
    begin
    if Pole[row,col] = 0 then
    begin
    Pole[row,col] ;= 100;
    KletkafForml.Canvas, row,col, 1);
    Open(row,col-lJ;
    Open(row-l,col];
    Open(row,col+1];
    Open(row+l,col];
    // примыкающие диагонально
    Open(row-1,col-l|;
    Open(row-1,col+1) ;
    Open(row+1,col-l);
    Open(row+1,col+1);
    end
    else
    if (Pole[row,col] < 100] and (Pole[row,col] <> -3) then
    begin
    Pole[row,col] := Pole[row,col] + 100;
    Kletka(Forml.Canvas, row, col, 1);
    end;
    end;
    // новая игра — генерирует новое поле
    procedure NewGame();
    var
    row,col : integer; // координаты клетки
    n : integer; // количество поставленных мин
    k : integer; // кол-во мин в соседних клетках
    begin
    // очистим эл-ты массива, соответствующее клеткам
    // игрового поля
    for row :=1 to MR do
    for col :=1 to MC do
    Pole trow,col] := 0;
    // расставим мины
    Randomized; // инициализация ГСЧ
    n :=0; // кол-во мин
    repeat
    row := Random(MR) + 1;
    col := Random(MC) + 1;
    it (Pole[row,col] о Э) then
    begin
    Pole[row,col] := 9;
    n := n+1;
    end;
    until (n = NM);
    // для каждой клетки вычислим
    // кол-во мин в соседних клетках
    for row := 1 to MR do
    for col := 1 to MC do
    if (Pole£row,col] <> 9) then
    begin
    k :=0 ;
    if Pole[row-l,col-l] = 9 then inc(k);
    if Pole[row-l,col] = 9 then inc(k);
    if Pole[row-l,col+l] = 9 then inc(k);
    if Pole[row,col-l] = 9 then inc(k);
    if Pole[row,col+l] - 9 then inc(k);
    if Pole[row-t-l,col-1! = 9 then inc(k);
    if Pole[row+l,col] = 9 then inc(k);
    if Pole[row+l,col+l] = 9 then inc(k);
    Pole[tow,col] := k;
    end;
    status := 0; // начало игры
    nMin := 0; // нет обнаруженных мин
    nFlag := 0; // нет флагов
    end;
    // рисуем мину
    Procedure Mina(Canvas : TCanvas; x, у : integer);
    begin
    with Canvas do
    begin
    Brush.Color := clGreen;
    Pen.Color :- clBlack;
    Rectangle(x+16,y+26,x+24,y+30);
    Rectangle(x+8,y+30,x+16,y+34);
    Rectangle(x+24,y+30,x+32,y+34);
    Pie(x+6,y+28,x+34,y+44,x+34,y+36,x+6,y+36)
    MoveTo(x+12,y+32); LineTo(x+26,y+32);
    MoveTo(x+8,y+36|; LineTo(x+32,y+36);
    MoveTo(x+20,y+22); LineTo(x+20,y+26);
    MoveTo(x+8, y+30); LineTo(x+6,y+28);
    MoveTo(x+32,y+30); LineTo(x+34,yi-28);
    end;
    end;
    // рисуем флаг
    Procedure Flag(Canvas : TCanvas; x, у ; integer);
    var
    p : array 10..3] of TPoint; // координаты точек флажке
    m : array [0..4] of TPoint; // буква М
    begin
    // зададим координаты точек флажка
    р[0].х =х+4; р[0].у:=у+4;
    р[1].х =х+30; р[1].у:=у+12;
    р[2].х =х+4; р[2].у:=у+20;
    р[3].х =х+4; р[3].у:=у+36; // нижняя точка древка
    m[0].х =х+4; m[0].у:=у+14;
    m[1].х =х+8; m[1].у:=у+8;
    m[2].х =х+10; m[2].у:=у+10;
    m[3].х =х+12; m[3].у:=у+8;
    m[4],x:=x+12; m[4].у:=у+14;
    with Canvas do
    begin
    // установим цвет кисти и карандаша
    Brush.Color := clRed;
    Pen.Color := clRed;
    Polygon(p); // флажок
    // древко
    Pen.Color := clBlack;
    MoveTo(p[0].x, p[0].y);
    LineTo(p[3].x, p[3].y);
    // буква М
    Pen.Color : = clWhite;
    Polyline(m);
    Pen.Color := clBlack;
    end;
    end;
    // выбор из меню ? команды О программе
    procedure TForml.mClick(Sender: TObject);
    begin
    AboutForm.Top := Trunc(Forml.Top + Forml.Height/2— AboutForm.Height/2);
    AboutForm.Left := Trunc(Forml.Left +Forml.Width/2- AboutForm.Width/2);
    AboutForm.ShowModal;
    end;
    procedure TForml.FormlCreatefSender: TObject);
    var
    row,col : integer;
    begin
    // в неотображаемые эл-гы массива, которые соответствуют
    // клеткам по границе игрового поля, запишем число -3.
    // это значение используется функцией Open для завершения
    // рекурсивного процесса открытия соседних пустых клеток
    for row :=0 to MR+1 do
    for col :=0 to MC+1 do
    Pole[row,col] := -3;
    NewGame(); // "разбросать" мины
    Forml.ClientHeight := H*MR + 1;
    Forml.ClientWidth := W'MC + 1;
    end;
    // нажатие кнопки мыши на игровом поле
    procedure TForml.FormlMouseDownlSender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
    var
    row, col : integer;
    begin
    if status = 2 // игра завершена
    then exit;
    if status = 0 then // первый щелчок
    status := 1;
    // преобразуем координаты мыши в индексы
    row := Trunc(y/H) + 1;
    col := Trunc(x/H) + 1;
    if Button = rnbLeft then
    begin
    if Pole[row,col] = 9 then
    begin // открыта клетка, в которой есть мина
    Pole[row,col] := Pole[row,col] + 100;
    status := 2; // игра закончена
    ShowPole(Forml.Canvas, status);
    end
    else if Pole[row,col] < 9 then
    Open(row,col);
    end
    else
    if Button = mbRight then
    if Pole[row,col] > 200 then
    begin
    // уберем флаг и закроем клетку
    nFlag := nFlag — 1;
    Pole[row,col] := Pole[row,col] -200;// уберем флаг
    x : = (col-1)- W + 1;
    у := (row-1)* H + 1;
    Canvas.Brush.Color := clLtGray;
    Canvas.Rectangle(x-l,y-l,x+W,y+H];
    end
    else
    begin // поставить в клетку флаг
    nFlag := nFlag + 1;
    if Pole[row,col] = 9
    then nMin := nMin + 1;
    Pole[row,col]:=Pole[row,col]+200;// поставили флаг
    if (nMin - MM) and (nFlag = NM) then
    begin
    status := 2; // игра закончена
    ShowPole(Forml.Canvas, status);
    end
    else KletkafForml.Canvas, row, col, status);
    end;
    end;
    // выбор меню Новая игра
    procedure TForml.NlClick(Sender: TObject);
    begin
    NewGame();
    ShowPole(Forml.Canvas,status);
    end;
    //выбор из меню ? команды Справка
    procedure TForml.N3Click(Sender: TObject);
    var
    HelpFile : string; // файл справки
    HelpTopic : string; // раздел справки
    pwHelpFile : PWideChar; // файл справки (указатель на WideChar-строку)
    pwHelpTopic : PWideChar; // раздел (указатель на HideChar-строку)
    begin
    HelpFile := 'saper.chm';
    HelpTopic := 'saper_02.htm';
    // выделить память для tiideChar строк
    GetMemfpwHelpFile, Length(HelpFile) * 2);
    GetMem(pwHelpTopic, Length(HelpTopic]*2);
    // преобразовать ANSI-строку в WideString-строку
    pwHelpFile := StringToWideChar(HelpFile,pwHelpFile,MAX_PATH*2);
    pwHelpTopic := StringToWideChar(HelpTopic,pwHelpTopic,32);
    // вывести справочную информацию
    Forml.Hhopenl.OpenHelplpwHelpFile,pwHelpTopic);
    end;
    procedure TForml.FormlPaint(Sender: TObject);
    begin
    ShowPole(Forml.Canvas, status);
    end;
    end.

  19. #139
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي

    كار با string


    unit stringwork;

    interface
    function InversionString (Sx: string ): string ;
    function LTrimUnChar (UnChar, Sx: string ): string ;
    function RTrimUnChar (UnChar, Sx: string ): string ;
    function AllTrimUnChar (UnChar, Sx: string ): string ;
    function CountWord (UnChar, Sx: string ): integer ;
    Implementation
    Reverses {string}
    function InversionString (Sx: string ): string ;
    Var
    I: integer ;
    begin
    Result: = Sx;
    if Length (Sx)> 0 then begin
    Result: = '' ;
    for I: = Length (Sx) downto 1 do
    begin
    Result: = Result + Sx ;
    end ;
    end ;
    end ;

    {left} Removes NEsimvoly
    function LTrimUnChar (UnChar, Sx: string ): string ;
    / / UnChar - string delimiters (not characters). Analogue of the
    / / Sx - the input string
    Var
    YesExit: byte ;
    begin
    Result: = Sx;
    if (length (Sx)> 0 ) and (length (UnChar)> 0 ) then begin
    YesExit: = 0 ;
    while YesExit <= 0 do
    begin
    if POS (Result [ 1 ], UnChar)> 0 then begin
    Delete (Result, 1 , 1 );
    end
    else begin
    YesExit: = 2 ;
    end ;
    if length (Result) <= 0 then YesExit: = 1 ;
    end ;
    end ;
    end ;

    {right} Removes NEsimvoly
    function RTrimUnChar (UnChar, Sx: string ): string ;
    / / UnChar - string delimiters (not characters). Analogue of the
    / / Sx - the input string
    begin
    Result: = InversionString (Sx);
    Result: = LTrimUnChar (UnChar, Result);
    Result: = InversionString (Result);
    end ;

    {Removes NEsimvoly left and right}
    function AllTrimUnChar (UnChar, Sx: string ): string ;
    / / UnChar - string delimiters (not characters). Analogue of the
    / / Sx - the input string
    begin
    Result: = LTrimUnChar (UnChar, Sx);
    Result: = RTrimUnChar (UnChar, Result);
    end ;

    / / Specifies the number of words per line
    function CountWord (UnChar, Sx: string ): integer ;
    / / UnChar - string delimiters (not characters). Analogue of the
    / / Sx - the input string
    var
    InWord: byte ;
    I: integer ;
    begin
    Result: = 0 ;
    InWord: = 0 ;
    I: = 0 ;
    while I <length (Sx) do
    begin
    I: = I + 1 ;
    if POS (Sx , UnChar) <= 0 then begin
    if InWord <= 0 then Result: = Result + 1 ; / / Go to the beginning of words
    InWord: = 1 ; / / We are within a word
    end
    else begin
    InWord: = 0 ; / / We are outside of the words
    end ;
    end ;
    end ;
    end .

  20. #140
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي


    The module works with resources in PE files, which works correctly in all versions of Windows. The basis was taken module work with the resources of Mathias Rauen . features:

    1- Extract icons from resources without losing their color and keeping all the nested icons.
    2- Adding a new resource
    3- Modify an existing resource
    4- Delete a Resource
    5- Working with the resources of various languages
    6- etc.


    دانلود
    آخرین ویرایش به وسیله SayeyeZohor : پنج شنبه 05 اردیبهشت 1392 در 02:04 صبح

  21. #141
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي


    This library allows you to get full information about the
    Bios
    Audio Card
    HDD
    Printer
    Display
    Keyboard
    Processor
    CD-Rom
    Battery (if applicable)
    Operating system
    "Mouse"
    Random access memory
    Processes PC
    OS services
    Desktop
    Autostart
    Network equipment
    Accounts in the OS
    Shared folders
    Printing on the printer
    USB
    Hard disk partitions
    Operating System Environment Variables
    and all that you can use in your application.



    لينك دانلود اصلاح شد
    GLibWMI Component Library 1.6 beta
    آخرین ویرایش به وسیله SayeyeZohor : پنج شنبه 05 اردیبهشت 1392 در 14:09 عصر

  22. #142

    نقل قول: سورسهاي نمونه آموزشي

    نقل قول نوشته شده توسط SayeyeZohor مشاهده تاپیک

    This library allows you to get full information about the
    Bios
    Audio Card
    HDD
    Printer
    Display
    Keyboard
    Processor
    CD-Rom
    Battery (if applicable)
    Operating system
    "Mouse"
    Random access memory
    Processes PC
    OS services
    Desktop
    Autostart
    Network equipment
    Accounts in the OS
    Shared folders
    Printing on the printer
    USB
    Hard disk partitions
    Operating System Environment Variables
    and all that you can use in your application.



    GLibWMI Component Library 1.6 beta
    این سایت ، چرا نمیشه ازش دانلود کرد؟


  23. #143
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

  24. #144
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي


  25. #145
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي


  26. #146
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي

    اینم یک مسیج دیالوگ خفن


    function MessageDlgPosSetFont(const Msg: string; DlgType: TMsgDlgType;
    Buttons: TMsgDlgButtons; HelpCtx: Longint;
    X, Y: Integer;
    sFontName: string; iFontSize: Integer; FsStyle: TFontStyles): Integer;
    begin
    with CreateMessageDialog(Msg, DlgType, Buttons) do
    try
    HelpContext := HelpCtx;
    if X >= 0 then Left := X;
    if Y >= 0 then Top := Y;
    // set the font name, size and style
    Font.Name:=sFontName;
    Font.Size:=iFontSize;
    Font.Style:=fsStyle;
    Result := ShowModal;
    finally
    Free;
    end;
    end;

  27. #147
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي

    اینم ساخت یک logeer برای برنامه هاتون


    procedure LogError(E: Exception);
    var
    sFileName : string;
    errLogList : TStringList;
    begin
    sFileName := ExtractFilePath(Application.EXEName) + 'error.log';
    errLogList := TStringList.Create;
    try
    if FileExists(sFileName) then errLogList.LoadFromFile(sFileName);
    with errLogList do
    begin
    Add('');
    Add('.: Sayeye Zohor Software Group :.');
    Add('Error Time Stamp: ' + FormatDateTime('hh:nn am/pm', Now) + ' on ' + FormatDateTime('mm/dd/yy', Now));
    Add('Error Class: ' + E.ClassName);
    Add('Error Message: ' + E.Message);
    SaveToFile(sFileName);
    end;
    //with
    finally
    errLogList.Free;
    end;
    end;



    بابا اطلاعاتتون رو نشر بدین

  28. #148
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي


  29. #149
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي


  30. #150
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي


    ...bring (force) a Window to the foreground?
    Author: unknown
    Homepage: http://www.eccentrica.org/gabr/gp/fi...msdnlookup.htm
    [ Print tip ]

    Tip Rating (31):



    {
    Windows 98/2000 doesn't want to foreground a window when
    some other window has the keyboard focus.
    ForceForegroundWindow is an enhanced SetForeGroundWindow/bringtofront
    function to bring a window to the front.
    }


    {
    Manchmal funktioniert die SetForeGroundWindow Funktion
    nicht so, wie sie sollte; besonders unter Windows 98/2000,
    wenn ein anderes Fenster den Fokus hat.
    ForceForegroundWindow ist eine "verbesserte" Version von
    der SetForeGroundWindow API-Funktion, um ein Fenster in
    den Vordergrund zu bringen.
    }


    function ForceForegroundWindow(hwnd: THandle): Boolean;
    const
    SPI_GETFOREGROUNDLOCKTIMEOUT = $2000;
    SPI_SETFOREGROUNDLOCKTIMEOUT = $2001;
    var
    ForegroundThreadID: DWORD;
    ThisThreadID: DWORD;
    timeout: DWORD;
    begin
    if IsIconic(hwnd) then ShowWindow(hwnd, SW_RESTORE);

    if GetForegroundWindow = hwnd then Result := True
    else
    begin
    // Windows 98/2000 doesn't want to foreground a window when some other
    // window has keyboard focus

    if ((Win32Platform = VER_PLATFORM_WIN32_NT) and (Win32MajorVersion > 4)) or
    ((Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and
    ((Win32MajorVersion > 4) or ((Win32MajorVersion = 4) and
    (Win32MinorVersion > 0)))) then
    begin
    // Code from Karl E. Peterson, www.mvps.org/vb/sample.htm
    // Converted to Delphi by Ray Lischner
    // Published in The Delphi Magazine 55, page 16

    Result := False;
    ForegroundThreadID := GetWindowThreadProcessID(GetForegroundWindow, nil);
    ThisThreadID := GetWindowThreadPRocessId(hwnd, nil);
    if AttachThreadInput(ThisThreadID, ForegroundThreadID, True) then
    begin
    BringWindowToTop(hwnd); // IE 5.5 related hack
    SetForegroundWindow(hwnd);
    AttachThreadInput(ThisThreadID, ForegroundThreadID, False);
    Result := (GetForegroundWindow = hwnd);
    end;
    if not Result then
    begin
    // Code by Daniel P. Stasinski
    SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, @timeout, 0);
    SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, TObject(0),
    SPIF_SENDCHANGE);
    BringWindowToTop(hwnd); // IE 5.5 related hack
    SetForegroundWindow(hWnd);
    SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, TObject(timeout), SPIF_SENDCHANGE);
    end;
    end
    else
    begin
    BringWindowToTop(hwnd); // IE 5.5 related hack
    SetForegroundWindow(hwnd);
    end;

    Result := (GetForegroundWindow = hwnd);
    end;
    end; { ForceForegroundWindow }


    // 2. Way:
    //**********************************************

    procedure ForceForegroundWindow(hwnd: THandle);
    // (W) 2001 Daniel Rolf
    // http://www.finecode.de
    // rolf@finecode.de
    var
    hlp: TForm;
    begin
    hlp := TForm.Create(nil);
    try
    hlp.BorderStyle := bsNone;
    hlp.SetBounds(0, 0, 1, 1);
    hlp.FormStyle := fsStayOnTop;
    hlp.Show;
    mouse_event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
    mouse_event(MOUSEEVENTF_ABSOLUTE or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
    SetForegroundWindow(hwnd);
    finally
    hlp.Free;
    end;
    end;

    // 3. Way:
    //**********************************************
    // by Thomas Stutz

    {
    As far as you know the SetForegroundWindow function on Windows 98/2000 can
    not force a window to the foreground while the user is working with another window.
    Instead, SetForegroundWindow will activate the window and call the FlashWindowEx
    function to notify the user. However in some kind of applications it is necessary
    to make another window active and put the thread that created this window into the
    foreground and of course, you can do it using one more undocumented function from
    the USER32.DLL.

    void SwitchToThisWindow (HWND hWnd, // Handle to the window that should be activated
    BOOL bRestore // Restore the window if it is minimized
    );

    }

    procedure SwitchToThisWindow(h1: hWnd; x: bool); stdcall;
    external user32 Name 'SwitchToThisWindow';
    {x = false: Size unchanged, x = true: normal size}


    procedure TForm1.Button2Click(Sender: TObject);
    begin
    SwitchToThisWindow(FindWindow('notepad', nil), True);
    end;

  31. #151
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي


    function StrToAnsiFileName(s: string): string;
    var
    i: integer;
    begin
    result := '';
    for i := 1 to length(s) do
    if s[i] in ['0'..'9', 'a'..'z', 'A'..'Z', '_', '.', ' '] then
    result := result + s[i];
    end;

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    ShowMessage(StrToAnsiFileName('ÓáÇã adff 13.jpg'));
    end;

  32. #152
    توابع تبدیل تاریخ با دقت 5000 سال
    پذیرش پروژه، کامپوننت، آموزش برنامه نویسی (دلفی، اس کیو ال، ..) -> 09123780840

    دوستای گلم حمایت کنید : https://cafebazaar.ir/app/com.nikanmehr.marmarxword/


    نرم افزار پخش مویرگی

  33. #153
    کاربر دائمی آواتار سعید صابری
    تاریخ عضویت
    اردیبهشت 1387
    محل زندگی
    برازجان
    پست
    1,431

    نقل قول: سورسهاي نمونه آموزشي

    یک تابع ساده برای تبدیل به string


    function ValToString(Value: Variant): String;
    begin
    case TVarData(Value).VType of
    varSmallInt,
    varInteger : Result := IntToStr(Value);
    varSingle,
    varDouble,
    varCurrency : Result := FloatToStr(Value);
    varDate : Result := FormatDateTime('dd.mm.yyyy', Value);
    varBoolean : if Value then Result := 'T' else Result := 'F';
    varString : Result := Value;
    else Result := '';
    end;
    end;

  34. #154
    کاربر دائمی آواتار SayeyeZohor
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ا-ص-ف-ه-ا-ن
    پست
    631

    نقل قول: سورسهاي نمونه آموزشي

    استفاده از تابع GetAsyncKeyState برای تشخیص رویداد


    procedure TForm1.Timer1Timer(Sender: TObject);
    var
    i : integer;
    begin
    for i:=8 To 222 do
    begin
    if GetAsyncKeyState(i)=-32767 then
    begin
    case i of
    8 : memo1.Lines[memo1.Lines.count-1] := copy(memo1.Lines[memo1.Lines.count-1],1,length(memo1.Lines[memo1.Lines.count-1])-1); //Backspace
    9 : memo1.text:=memo1.text+'[Tab]';
    13 : memo1.text:=memo1.text+#13#10; //Enter
    17 : memo1.text:=memo1.text+'[Ctrl]';
    27 : memo1.text:=memo1.text+'[Esc]';
    32 :memo1.text:=memo1.text+' '; //Space
    // Del,Ins,Home,PageUp,PageDown,End
    33 : memo1.text := Memo1.text + '[Page Up]';
    34 : memo1.text := Memo1.text + '[Page Down]';
    35 : memo1.text := Memo1.text + '[End]';
    36 : memo1.text := Memo1.text + '[Home]';
    //Arrow Up Down Left Right
    37 : memo1.text := Memo1.text + '[Left]';
    38 : memo1.text := Memo1.text + '[Up]';
    39 : memo1.text := Memo1.text + '[Right]';
    40 : memo1.text := Memo1.text + '[Down]';

    44 : memo1.text := Memo1.text + '[Print Screen]';
    45 : memo1.text := Memo1.text + '[Insert]';
    46 : memo1.text := Memo1.text + '[Del]';
    145 : memo1.text := Memo1.text + '[Scroll Lock]';

    //Number 1234567890 Symbol !@#$%^&*()
    48 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+')'
    else memo1.text:=memo1.text+'0';
    49 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'!'
    else memo1.text:=memo1.text+'1';
    50 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'@'
    else memo1.text:=memo1.text+'2';
    51 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'#'
    else memo1.text:=memo1.text+'3';
    52 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'$'
    else memo1.text:=memo1.text+'4';
    53 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'%'
    else memo1.text:=memo1.text+'5';
    54 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'^'
    else memo1.text:=memo1.text+'6';
    55 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'&'
    else memo1.text:=memo1.text+'7';
    56 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'*'
    else memo1.text:=memo1.text+'8';
    57 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'('
    else memo1.text:=memo1.text+'9';
    65..90 : // a..z , A..Z
    begin
    if ((GetKeyState(VK_CAPITAL))=1) then
    if GetKeyState(VK_SHIFT)<0 then
    memo1.text:=memo1.text+LowerCase(Chr(i)) //a..z
    else
    memo1.text:=memo1.text+UpperCase(Chr(i)) //A..Z
    else
    if GetKeyState(VK_SHIFT)<0 then
    memo1.text:=memo1.text+UpperCase(Chr(i)) //A..Z
    else
    memo1.text:=memo1.text+LowerCase(Chr(i)); //a..z
    end;
    //Numpad
    96..105 : memo1.text:=memo1.text + inttostr(i-96); //Numpad 0..9
    106:memo1.text:=memo1.text+'*';
    107:memo1.text:=memo1.text+'&';
    109:memo1.text:=memo1.text+'-';
    110:memo1.text:=memo1.text+'.';
    111:memo1.text:=memo1.text+'/';
    144 : memo1.text:=memo1.text+'[Num Lock]';

    112..123: //F1-F12
    memo1.text:=memo1.text+'[F'+IntToStr(i - 111)+']';

    186 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+':'
    else memo1.text:=memo1.text+';';
    187 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'+'
    else memo1.text:=memo1.text+'=';
    188 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'<'
    else memo1.text:=memo1.text+',';
    189 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'_'
    else memo1.text:=memo1.text+'-';
    190 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'>'
    else memo1.text:=memo1.text+'.';
    191 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'?'
    else memo1.text:=memo1.text+'/';
    192 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'~'
    else memo1.text:=memo1.text+'`';
    219 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'{'
    else memo1.text:=memo1.text+'[';
    220 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'|'
    else memo1.text:=memo1.text+'\';
    221 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'}'
    else memo1.text:=memo1.text+']';
    222 : if GetKeyState(VK_SHIFT)<0 then memo1.text:=memo1.text+'"'
    else memo1.text:=memo1.text+'''';
    end;
    end;
    end;
    end;

  35. #155
    کاربر دائمی آواتار سعید صابری
    تاریخ عضویت
    اردیبهشت 1387
    محل زندگی
    برازجان
    پست
    1,431

    نقل قول: سورسهاي نمونه آموزشي

    ایجاد حاشیه یا همون Margin در Memo

    var Rect: TRect;
    begin
    SendMessage( Memo1.Handle, EM_GETRECT, 0, LongInt(@Rect));
    Rect.Left:= 30;
    SendMessage(Memo1.Handle, EM_SETRECT, 0, LongInt(@Rect));
    Memo1.Refresh;



  36. #156

    بدست آوردن لیست Driver های نصب شده روی MSWindows

    دیگه به توضیح نیاز نداره

    unit unt_DriverList;

    (*

    Coded By : Behrooz Abbassi (Saam)

    *)
    interface

    Uses
    Vcl.Graphics,
    Vcl.Controls,
    Vcl.ComCtrls,
    Winapi.Windows,
    Winapi.PsAPI,
    Winapi.ShellAPI,
    System.StrUtils,
    System.SysUtils;

    type
    TDriverList = class(TObject)
    private
    FIcon: TIcon;
    FSmallIcon: TImageList;
    function Get_WinSysDir: string;
    function Get_FileIcon(const fFileName: string): TIcon;

    const
    SErrorMessage = 'Failed to enumerate drivers. Make sure ' +
    'PSAPI.DLL is installed on your system.';
    public
    constructor Create;
    destructor Destroy;
    procedure Get_DriverList(Listview: TListView);
    end;

    implementation

    { TDriverList }

    constructor TDriverList.Create;
    begin
    FSmallIcon := TImageList.Create(nil);
    FIcon := TIcon.Create;
    end;

    destructor TDriverList.Destroy;
    begin
    FSmallIcon.Free;
    FIcon.Free;
    end;

    procedure TDriverList.Get_DriverList(Listview: TListView);
    var
    strTempName: string;
    I: Integer;
    dwCount: DWORD;
    FDrvlist: array of Pointer;
    BigArray: array [0 .. $3FFF - 1] of DWORD;
    DrvName: array [0 .. MAX_PATH] of char;
    varout: word;
    begin
    Listview.SmallImages := FSmallIcon;
    if not EnumDeviceDrivers(@BigArray, SizeOf(BigArray), dwCount) then
    raise Exception.Create(SErrorMessage);

    SetLength(FDrvlist, dwCount div SizeOf(DWORD));
    Move(BigArray, FDrvlist[0], dwCount);

    for I := low(FDrvlist) to High(FDrvlist) do
    begin

    if GetDeviceDriverFileName(FDrvlist[I], DrvName, SizeOf(DrvName)) > 0 then
    begin
    with Listview.Items.Add do
    begin

    Caption := ExtractFileName(DrvName);

    if FileExists(Get_WinSysDir + '\' + Caption) then
    strTempName := Get_WinSysDir + '\' + Caption
    else if FileExists(Get_WinSysDir + '\Drivers\' + Caption) then
    strTempName := Get_WinSysDir + '\Drivers\' + Caption
    else
    strTempName := DrvName;

    if LeftStr(strTempName, Length('\??\')) = '\??\' then
    begin
    strTempName := ReplaceStr(strTempName, '\??\', '');
    end;
    if LeftStr(strTempName, Length('\SystemRoot')) = '\SystemRoot' then
    begin
    strTempName := LeftStr(Get_WinSysDir, 2) + ReplaceStr(strTempName,
    'SystemRoot', 'Windows');
    end;
    if LeftStr(strTempName, Length('\Windows')) = '\Windows' then
    begin
    strTempName := LeftStr(Get_WinSysDir, 2)+strTempName;
    end;
    SubItems.Add(strTempName);
    SubItems.Add(Format('%p', [FDrvlist[I]]));

    if FileExists(strTempName) then
    ImageIndex := FSmallIcon.AddIcon(Get_FileIcon(strTempName));

    end;
    end;
    end;
    end;

    function TDriverList.Get_FileIcon(const fFileName: string): TIcon;
    function GetIcon(const FileN: string; bLIcon: Boolean = true): TSHFileInfo;
    begin
    if bLIcon then
    begin
    ShGetFileInfo(Pchar((FileN)), 0, Result, SizeOf(Result), SHGFI_TYPENAME or
    SHGFI_ICON or SHGFI_LARGEICON or SHGFI_LARGEICON);
    end
    else if not(bLIcon) then
    begin
    ShGetFileInfo(Pchar((FileN)), 0, Result, SizeOf(Result), SHGFI_TYPENAME or
    SHGFI_ICON or SHGFI_LARGEICON or SHGFI_SMALLICON);
    end;
    end;

    begin { Small }
    FIcon.Handle := GetIcon(fFileName, False).HICON;
    Result := FIcon;
    end;

    function TDriverList.Get_WinSysDir: string;
    {$IFDEF MSWINDOWS }
    var
    Buffer: array [0 .. 255] of char;
    begin
    GetWindowsDirectory(Buffer, MAX_PATH);
    Result := StrPas(Buffer) + '\';
    {$ENDIF MSWINDOWS }
    end;

    end.


    نحوه استفاده :
    var
    DL: TDriverList;
    begin
    DL := TDriverList.Create;
    try
    DL.Get_DriverList(LV);
    finally
    DL.Free;
    end;

    که LV یک کنترل ListView اه.

    DL.jpg

    موفق باشید.

    SAAM
    Everything that has a beginning has an end. ... The End?



  37. #157

    نقل قول: سورسهاي نمونه آموزشي

    درود به همه
    با این نمونه برنامه میتونید توی console از نوشته های رنگی و گل منگولی استفاده کنید.
    program Project1;

    {$APPTYPE CONSOLE}

    uses
    System.SysUtils, Winapi.Windows;

    var
    hConsole: NativeUInt;

    const
    cl_Black = 0;
    cl_Navy = 1;
    cl_Green = 2;
    cl_Teal = 3;
    cl_Maroon = 4;
    cl_Purple = 5;
    cl_Brown = 6;
    cl_Silver = 7;
    cl_Gray = 8;
    cl_Blue = 9;
    cl_Lime = 10;
    cl_Aqua = 11;
    cl_Red = 12;
    cl_Fuchsia = 13;
    cl_Yellow = 14;
    cl_White = 15;

    begin
    hConsole := GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTitle('Colored Console in Delphi XE3');
    SetConsoleTextAttribute(hConsole, cl_Yellow);

    Writeln('Coded by : Opc0d3 ');
    SetConsoleTextAttribute(hConsole, cl_Fuchsia);
    Writeln('-----------------------------------------');
    SetConsoleTextAttribute(hConsole, cl_red);
    Writeln(' Barnamenevis.ORG ');

    SetConsoleTextAttribute(hConsole, cl_Green);
    Writeln('-----------------------------------------');
    SetConsoleTextAttribute(hConsole, cl_Blue);

    SetConsoleTextAttribute(hConsole, RGB(100, 0, 0));
    Writeln('ABCD');
    Readln;

    end.


    شاعر میگه این تابع بهتره ! بعد ویرایش :

    var
    hConsole: NativeUInt;
    i: Integer;
    type
    TColor = (cl_Black = 0, cl_Navy = 1, cl_Green = 2, cl_Teal = 3, cl_Maroon = 4,
    cl_Purple = 5, cl_Brown = 6, cl_Silver = 7, cl_Gray = 8, cl_Blue = 9,
    cl_Lime = 10, cl_Aqua = 11, cl_Red = 12, cl_Fuchsia = 13, cl_Yellow = 14,
    cl_White = 15);


    //
    Procedure WriteColored(const AText: AnsiString; ATextColor: TColor);
    begin
    hConsole := GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole, Ord(ATextColor));
    Writeln(AText);
    SetConsoleTextAttribute(hConsole, 15);
    end;

    مثال :
    WriteColored('yooooooooooooooooooooohOW!',cl_Green  );

    آخرین ویرایش به وسیله بهروز عباسی : سه شنبه 18 تیر 1392 در 11:05 صبح
    Everything that has a beginning has an end. ... The End?



  38. #158

    گرفتن لیست پروسه های در حال اجرا به همراه آدرس فایل اجرایی بدون نیاز به دسترسی Admin

    گرفتن لیست پروسه های در حال اجرا به همراه آدرس فایل اجرایی بدون نیاز به دسترسی Admin یا ... به وسیله توابع Process32First و Process32Next :

    function GetprocessList(ProcessList: TStrings): Boolean;
    var
    ContinueLoop: BOOL;
    FSnapshotHandle: THandle;
    FProcessEntry32: TProcessEntry32;
    begin
    ProcessList.Clear;
    FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    try
    FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
    ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);

    while Integer(ContinueLoop) <> 0 do
    begin
    ProcessList.Add(FProcessEntry32.szExeFile);
    ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
    end;
    finally
    CloseHandle(FSnapshotHandle);
    end;
    end;

  39. #159

    نقل قول: گرفتن لیست پروسه های در حال اجرا به همراه آدرس فایل اجرایی بدون نیاز به دسترسی Admin

    نقل قول نوشته شده توسط Mahan-1363 مشاهده تاپیک
    گرفتن لیست پروسه های در حال اجرا به همراه آدرس فایل اجرایی بدون نیاز به دسترسی Admin یا ... به وسیله توابع Process32First و Process32Next :

    function GetprocessList(ProcessList: TStrings): Boolean;
    var
    ContinueLoop: BOOL;
    FSnapshotHandle: THandle;
    FProcessEntry32: TProcessEntry32;
    begin
    ProcessList.Clear;
    FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    try
    FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
    ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);

    while Integer(ContinueLoop) <> 0 do
    begin
    ProcessList.Add(FProcessEntry32.szExeFile);
    ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
    end;
    finally
    CloseHandle(FSnapshotHandle);
    end;
    end;
    کُد شما در همه سیستم ها نمیتونه آدرس یا نام همه پروسه ها رو به درستی نمایش بده.
    نمیدونم این کُدها رو توی سایت گذاشتم یا نه، از ویندوز 32 XP تا WIn8 64 تست شده و جواب میده:

    function EnableDebugPrivileges: THandle;
    var
    lpLuid : TOKEN_PRIVILEGES;
    OldlpLuid : TOKEN_PRIVILEGES;
    ReturnLength : DWORD;
    begin
    if OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, Result) then begin
    if not LookupPrivilegeValue(nil, 'SeDebugPrivilege', lpLuid.Privileges[0].Luid) then
    RaiseLastOSError
    else
    begin
    lpLuid.PrivilegeCount := 1;
    lpLuid.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
    ReturnLength := 0;
    OldlpLuid := lpLuid;
    //Set the SeDebugPrivilege privilege
    if not AdjustTokenPrivileges(Result, False, lpLuid, SizeOf(OldlpLuid), OldlpLuid, ReturnLength) then
    RaiseLastOSError;
    end;
    end else
    RaiseLastOSError;
    end;

    function GetProcFullPathVista(ProcessId: Cardinal): string;
    var
    ProcessIdInfo: SYSTEM_PROCESS_ID_INFORMATION;
    begin
    Result := '';

    SetLength(Result, MAX_PATH);

    ProcessIdInfo.ProcessId := ProcessId;
    ProcessIdInfo.ImageName.Length := 0;
    ProcessIdInfo.ImageName.MaximumLength := MAX_PATH;
    ProcessIdInfo.ImageName.Buffer := @Result[1];

    NtQuerySystemInformation(88, @ProcessIdInfo, SizeOf(SYSTEM_PROCESS_ID_INFORMATION), nil);

    SetLength(Result, ProcessIdInfo.ImageName.Length div 2);
    Result := DevicePathToWin32Path(Result);
    end;

    function GetProcFullPathXP(ProcessId: Cardinal): string;
    var
    ProcessName: array[0..MAX_PATH - 1] of WideChar;
    ProcessHandle: THandle;
    TokenHandle: THandle;
    begin
    Result := '';
    TokenHandle := EnableDebugPrivileges;
    try
    ProcessHandle := OpenProcess(PROCESS_QUERY_INFORMATION, false, ProcessId);
    if (ProcessHandle = 0) or (ProcessHandle = INVALID_HANDLE_VALUE) then Exit;
    try
    if NtQueryInformationProcess(ProcessHandle, 27, @ProcessName[0], MAX_PATH, nil) = NT_STATUS_SUCCESS then
    Result := DevicePathToWin32Path(PUNICODE_STRING(@ProcessName[0])^.Buffer);
    finally
    CloseHandle(ProcessHandle);
    end;
    finally
    CloseHandle(TokenHandle);
    end;
    end;

  40. #160

    نقل قول: سورسهاي نمونه آموزشي

    کُد شما در همه سیستم ها نمیتونه آدرس یا نام همه پروسه ها رو به درستی نمایش بده.
    مثلا چه نسخه ای ؟
    طبق مستندات MSDN :

    Minimum supported client
    Windows XP [desktop apps only]

    Minimum supported server
    Windows Server 2003 [desktop apps only]
    من کدی که قرار دادم رو از ویندوز XP به بعد تو تمام سیستم عامل ها با شرایط مختلف و نسخه های مختلف سیستم عامل تست کردم ، اگز مشکلی دید بگید بررسی کنم .

    اگر قرار باشه کدی درست کار نکنه کد شما هست دوست عزیز ، قبل از نوشتن کد یا استفاده از کدهای موجود ، بررسی کنید ببینید طرف چی کار کرده و بعدا ممکنه براتون چه دردسرهایی درست کنه ، دوباره طبق مستندات MSDN :

    NtQuerySystemInformation

    [NtQuerySystemInformation may be altered or unavailable in future versions of Windows. Applications should use the alternate functions listed in this topic.]

    Remarks
    The NtQuerySystemInformation function and the structures that it returns are internal to the operating system and subject to change from one release of Windows to another. To maintain the compatibility of your application, it is better to use the alternate functions previously mentioned instead.

صفحه 4 از 6 اولاول ... 23456 آخرآخر

برچسب های این تاپیک

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •