کاربر فعال آیا یک ادمین هست
unit WindowsUser;
interface
  uses Windows;
//returns True if the currently logged Windows user has Administrator rights
function IsWindowsAdmin: Boolean;
implementation
const
  SECURITY_NT_AUTHORITY: TSIDIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 5)) ;
const
  SECURITY_BUILTIN_DOMAIN_RID = $00000020;
  DOMAIN_ALIAS_RID_ADMINS = $00000220;
function IsWindowsAdmin: Boolean;
var
  hAccessToken: THandle;
  ptgGroups: PTokenGroups;
  dwInfoBufferSize: DWORD;
  psidAdministrators: PSID;
  g: Integer;
  bSuccess: BOOL;
begin
  Result := False;
  bSuccess := OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True, hAccessToken) ;
  if not bSuccess then
  begin
    if GetLastError = ERROR_NO_TOKEN then
    bSuccess := OpenProcessToken(GetCurrentProcess, TOKEN_QUERY, hAccessToken) ;
  end;
  if bSuccess then
  begin
    GetMem(ptgGroups, 1024) ;
    bSuccess := GetTokenInformation(hAccessToken, TokenGroups, ptgGroups, 1024, dwInfoBufferSize) ;
    CloseHandle(hAccessToken) ;
    if bSuccess then
    begin
      AllocateAndInitializeSid(SECURITY_NT_AUTHORITY, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, psidAdministrators) ;
      for g := 0 to ptgGroups.GroupCount - 1 do
        if EqualSid(psidAdministrators, ptgGroups.Groups[g].Sid) then
        begin
          Result := True;
          Break;
        end;
      FreeSid(psidAdministrators) ;
    end;
    FreeMem(ptgGroups) ;
  end;
end;
end.
	سلام خسته نباشید من یک برنامه نوشتم با بانکهای sql server 2000
مشکل من اینه که هر موقع می خوام برنامه رو اجرا کنم باید اسم کامپیوترمو نامی که
من موقع نوشتن برنامه رو کامپیوترم بوده بدم
می شه لطفا منو تو این رابطه کمکم کنید
خیلی خیلی ممنونم
moongirl عزيز اگه ويژوال بيسيك رو ديده باشي دلفي يه چيزي توي مايه هاي همونه ولي با امكانات گرافيكي بيشتر شايد خيلي بيشتر و جالبتر .اين كه شما مهندسا جمع شدين با هم صحبت علمي مي كنين خيلي خوبه ولي ميشه يكيتون لطف كنه و به من صفر كيلومتر هم بگه اين دلفي كه ازش صحبت مي كنين چيه؟
سلام دوستان
من چند وقته به یاد گرفتن دلفی علاقه مند شدم
لطفاً شما که در این زمینه کار کردید راهنمایی کنید که چطور دلفی یاد بگیرم
قبلاً یه مقدار c++ کارکردم ولی نه بطور حرفه ای
ممنون میشم اگر ebook هم سراغ دارید برام بذارید
1- به جای sql از access استفاده کن.سلام
من اين ترم واسه درس پايگاه تلفيقي از دلفي و sql رو بايد كار كنم و پروژه تحويل بدم ولي هيچي از sql ياد ندارم شما چي پيشنهاد مي كنيد؟
چیز دیگه نمی خوای چایی بستنی میوه قهوه.....ماشين حساب مي خوام
 ( شوخی کردم به دل نگیر)با استفاده از کامپوننت ADOConnection می تونی به بیشتر پایگاه ها وصل شی.-مي خوام بتونم انواع پايگاه داده ها رو به دلفي مرتبط كنم. اگه برام ebook بذاريد يا كتاب معرفي كنيد ممنون مي شم.
با استفاده از کامپوننت ADOQuery می تونی هر نوع query به زبان sql بنویسی.-مي خوام توي دلفي از دستورات sql بخصوص ازselect تو در تو و پارامتري استفاده كنم.ايا امكانش هست؟
procedure ListFileDir(Path: string; FileList: TStrings); 
var 
  SR: TSearchRec; 
begin 
  if FindFirst(Path + '*.*', faAnyFile, SR) = 0 then 
  begin 
    repeat 
      if (SR.Attr <> faDirectory) then 
      begin 
        FileList.Add(SR.Name); 
      end; 
    until FindNext(SR) <> 0; 
    FindClose(SR); 
  end; 
end; 
procedure TForm1.Button1Click(Sender: TObject); 
begin 
  ListFileDir('C:\WINDOWS\', ListBox1.Items); 
end;
	procedure GetSubDirs(const sRootDir: string; slt: TStrings); 
var 
  srSearch: TSearchRec; 
  sSearchPath: string; 
  sltSub: TStrings; 
  i: Integer; 
begin 
  sltSub := TStringList.Create; 
  slt.BeginUpdate; 
  try 
    sSearchPath := AddDirSeparator(sRootDir); 
    if FindFirst(sSearchPath + '*', faDirectory, srSearch) = 0 then 
      repeat 
        if ((srSearch.Attr and faDirectory) = faDirectory) and 
          (srSearch.Name <> '.') and 
          (srSearch.Name <> '..') then 
        begin 
          slt.Add(sSearchPath + srSearch.Name); 
          sltSub.Add(sSearchPath + srSearch.Name); 
        end; 
      until (FindNext(srSearch) <> 0); 
    FindClose(srSearch); 
    for i := 0 to sltSub.Count - 1 do 
      GetSubDirs(sltSub.Strings[i], slt); 
  finally 
    slt.EndUpdate; 
    FreeAndNil(sltSub); 
  end; 
end;
	uses 
  ShellApi; 
procedure RenameDir(DirFrom, DirTo: string); 
var 
  shellinfo: TSHFileOpStruct; 
begin 
  with shellinfo do 
  begin 
    Wnd    := 0; 
    wFunc  := FO_RENAME; 
    pFrom  := PChar(DirFrom); 
    pTo    := PChar(DirTo); 
    fFlags := FOF_FILESONLY or FOF_ALLOWUNDO or 
              FOF_SILENT or FOF_NOCONFIRMATION; 
  end; 
  SHFileOperation(shellinfo); 
end; 
procedure TForm1.Button1Click(Sender: TObject); 
begin 
  RenameDir('C:\Dir1', 'C:\Dir2'); 
end;
	procedure TForm1.Button1Click(Sender: TObject); 
var 
freeSpace, totalSpace: Double; 
s: Char; 
begin 
// Drive letter 
// Laufwerksbuchstabe 
s := 'D'; 
 
freeSpace := DiskFree(Ord(s) - 64); 
totalSpace := DiskSize(Ord(s) - 64); 
 
label1.Caption := Format('Free Space: %12.0n', [freeSpace]); 
Label2.Caption := Format('Total Space: %12.0n', [totalSpace]); 
Label3.Caption := IntToStr(Round((totalSpace - freeSpace) / totalSpace * 100)) + 
' Percent used.'; 
end;
	function GetDirSize(dir: string; subdir: Boolean): Longint; 
var 
rec: TSearchRec; 
found: Integer; 
begin 
Result := 0; 
if dir[Length(dir)] <> '\' then dir := dir + '\'; 
found := FindFirst(dir + '*.*', faAnyFile, rec); 
while found = 0 do 
begin 
Inc(Result, rec.Size); 
if (rec.Attr and faDirectory > 0) and (rec.Name[1] <> '.') and (subdir = True) then 
Inc(Result, GetDirSize(dir + rec.Name, True)); 
found := FindNext(rec); 
end; 
FindClose(rec); 
end; 
 
procedure TForm1.Button1Click(Sender: TObject); 
begin 
label1.Caption := FloatToStr(GetDirSize('e:\download', False) / Sqr(1024)) + ' MBytes'; 
label2.Caption := FloatToStr(GetDirSize('e:\download', True) / Sqr(1024)) + ' MBytes'; 
end;
	function  FindFile(Path,Files:String):TStrings;
Var
  Dirs,Fill:String;
  IO,len,i:Integer;
  Search:TsearchRec;
Begin
Result:=TStringList.Create;
If Path='' then exit;
//While Pos(';',files)>0 do
//  Files[Pos(';',Files)]:=' ';       //****
Dirs:='';
If Path[Length(Path)]='\' then
  Delete(path,length(path),1);
Repeat
  I:=Length(Files);
  Repeat
    Fill:='';
    While (I>0) and (files[i]<>';') do //' ') do     //******
      Begin
        Fill:=files[i]+Fill;
        I:=i-1;
      end;
    I:=i-1;
    IO:=findFirst(path+'\'+fill,faAnyFile-faDirectory,Search);
    While Io=0 do
    Begin
      If (search.Name<>'.') and (search.name<>'..') then
        Result.Add(path+'\'+Search.name);
      IO:=FindNext(Search);
    end;
    FindClose(search);
  until I<1;
  IO:=FindFirst(Path+'\*.*',faAnyFile,Search);
  While IO=0 do
  Begin
      If (search.Name<>'.') and (search.name<>'..') and (search.Attr and FaDirectory>0) then
        Dirs:=Dirs+Path+'\'+Search.Name+#13;
      Io:=FindNext(search);
  end;
  FindClose(search);
  Len:=length(Dirs)-1;
  Io:=len;
  If Len>0 then
    Begin
      While (IO>0) and (Dirs[IO]<>#13) do Io:=IO-1;
      Path:=Copy(Dirs,IO+1,Len-IO);
      SetLength(Dirs,IO);
    end;
Until(len<0);
end;
	می خوام یه عکس رو توی فتوشاپ باز کنم
میشه از shellExecute استفاده کرد و open with کرد؟
من که نتونستم
راه دیگه ای هم هست؟
از این کد برای اجرای فایل استفاده می کنمکد:ShellExecute(hwnd(nil),'open','filename',nil,'filedirectory',0);
ولی پارامتراش نمی دونم هر کدوم به چه درد می خورن
توی help هم نیس![]()
فکر کنم باید از TFileOpenWith توی actionlist استفاده کنم
ولی بلد نیستم
آخه من چرا هیچی بلد نیستم![]()
ShellExecute(hwnd(nil),'open','2.exe','f:\1.bmp','d:\',1);
	
)
| Thread starter | عنوان | تالار | پاسخ ها | تاریخ | 
|---|---|---|---|---|
| 		
									
										
			 | 
نمونه برنامه و سورس دلفی + راهنمایی و رفع اشکال | Delphi | 8 | |
| M | dLL در دلفی | Delphi | 0 | |
| S | مهم : پروسیجر دلفی | Delphi | 5 | |
| 		
									
										
			 | 
کار با دستور شرطی if و فایل و نمایش پیام در دلفی | Delphi | 1 | |
| 		
									
										
			 | 
تابع تبدیل تاریخ میلادی به شمسی ((تقدیم به دوستان دلفی کار)) | Delphi | 0 |