Jump to content

KodeZwerg

Members
  • Content Count

    290
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by KodeZwerg

  1. KodeZwerg

    JEDI files cannot find windows files

    3rd wild guess: Re-Installed Delphi.... I wonder if there is some old data in registry or file system conflicting installation to work properly?
  2. KodeZwerg

    JEDI files cannot find windows files

    Okay, sad to hear 😞 Github say latest release is from 2015. My second wild guess would be looking for a more uptodate fork. May the fork be with you.
  3. KodeZwerg

    JEDI files cannot find windows files

    Just a guess, no professionell answer. (I do not use JEDI) Try open the first file that complain to compile. Modify 'uses' part with better name. Example: Uses Classes; <- before Uses System.Classes; <- after Try compile again, if it does not complain modified file anymore, you know what to do. As said, just a wild guess.
  4. KodeZwerg

    Totally new to this area

    Wikipedia look under 'Computing' to getting started.
  5. KodeZwerg

    Totally new to this area

    I lost reference of source, it was in my file archives inside embarcadero folder. After investigating my last source (i was aware of memory limit), i do trust what delphi is doing without going into every little bit of code and come to a new conclusion that all should make happy, hopefully. function GetSHA1(const FileName: string): string; begin Result := ''; if not FileExists(FileName) then Exit; Result := THashSHA1.GetHashStringFromFile(FileName); end; function GetMD5(const FileName: string): string; begin Result := ''; if not FileExists(FileName) then Exit; Result := THashMD5.GetHashStringFromFile(FileName); end; Sorry, no fix for my first example will be made by me. I prefer doing on my own. (You still need 'uses System.Hash' to work)
  6. KodeZwerg

    Totally new to this area

    Thanks @David Heffernan for pointing that out. Heres a quick and dirty fix. It is limited by memory and fail if dont fit in RAM. Uses System.SysUtils, System.IOUtils, System.Hash; function HashFileSHA1(const FileName: string): string; var HashSHA1: THashSHA1; Memory: TBytes; begin Result := ''; if FileExists(FileName) then begin Memory := TFile.ReadAllBytes(FileName); HashSHA1 := THashSHA1.Create; HashSHA1.Update(Memory); Result := HashSHA1.HashAsString; end; end;
  7. KodeZwerg

    Totally new to this area

    Here small code for Delphi to get hashes. function GetFileHashMD5(FileName: WideString): String; var HashMD5: THashMD5; Stream: TStream; Readed: Integer; Buffer: PByte; BufLen: Integer; begin HashMD5 := THashMD5.Create; BufLen := 16 * 1024; Buffer := AllocMem(BufLen); try Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); try while Stream.Position < Stream.Size do begin Readed := Stream.Read(Buffer^, BufLen); if Readed > 0 then begin HashMD5.update(Buffer^, Readed); end; end; finally Stream.Free; end; finally FreeMem(Buffer) end; Result := HashMD5.HashAsString; end; function GetFileHashSHA1(FileName: WideString): String; var HashSHA: THashSHA1; Stream: TStream; Readed: Integer; Buffer: PByte; BufLen: Integer; begin HashSHA := THashSHA1.Create; BufLen := 16 * 1024; Buffer := AllocMem(BufLen); try Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); try while Stream.Position < Stream.Size do begin Readed := Stream.Read(Buffer^, BufLen); if Readed > 0 then begin HashSHA.update(Buffer^, Readed); end; end; finally Stream.Free; end; finally FreeMem(Buffer) end; Result := HashSHA.HashAsString; end; Uses Sytem.Hash <<- insert that into your uses clause Maybe that code help you. Taken from Embarcadero Examples. Ps. FMX might be wrong for this topic 🙂
  8. KodeZwerg

    Totally new to this area

    Hashes and Checksums are calculated over that file, it aint 'branded/marked'. The only way is to modify image to get a modified result from one of those methods (sha1/md5/crc) You can not define such.
  9. KodeZwerg

    Enumerating Windows Sounds

    My bad. Your best. Peace
  10. KodeZwerg

    Enumerating Windows Sounds

    Above code will readout registry data. Modify Form1.Memo1 to your needs. //edit Code aint perfect designed, just a working release. Have fun 🙂
  11. KodeZwerg

    Enumerating Windows Sounds

    procedure GetRegistrySounds; var phkResult: HKEY; dwIndex: DWORD; HResult: Longint; lpName: LPWSTR; SubKeyNames: TStringList; i: Integer; Len: Longint; Buf: array[0..1023] of Char; dwResult: DWORD; ResultString: string; begin SubKeyNames := TStringList.Create; try dwIndex := 0; lpName := StrAlloc(1024); HResult := RegOpenKeyEx(HKEY_CURRENT_USER, PChar('AppEvents\Schemes\Apps\.Default'), 0, KEY_READ, phkResult); if (HResult = ERROR_SUCCESS) then begin while (HResult = ERROR_SUCCESS) do begin HResult := RegEnumKey(phkResult, dwIndex, lpName, 1024); if (HResult = ERROR_SUCCESS) then begin SubKeyNames.Add(lpName); Inc(dwIndex); end; end; RegCloseKey(phkResult); end; StrDispose(lpName); for i := 0 to (SubKeyNames.Count - 1) do begin if (RegOpenKeyEx(HKEY_CURRENT_USER, PChar('AppEvents\Schemes\Apps\.Default\' + SubKeyNames[i] + '\.Current'), 0, KEY_READ, phkResult) = ERROR_SUCCESS) then begin Len := 1024 * SizeOf(Char); case RegQueryValueEx(phkResult, PChar(''), nil, nil, PByte(@Buf[0]), @Len) of ERROR_SUCCESS: SetString(ResultString, Buf, Len div SizeOf(Char) - 1); ERROR_MORE_DATA: begin SetLength(ResultString, Len div SizeOf(Char) - 1); if (RegQueryValueEx(phkResult, PChar(''), nil, nil, PByte(ResultString), @Len) = ERROR_SUCCESS) then SetLength(ResultString, Len div SizeOf(Char) - 1) else ResultString := ''; end; end; RegCloseKey(phkResult); if (ResultString <> '') then begin dwResult := ExpandEnvironmentStrings(PChar(ResultString), buf, 1024); if (dwResult <> 0) then ResultString := string(buf); // here we have a result to work with Form1.Memo1.Lines.Add(ResultString); end; end; end; finally SubKeyNames.Free; end; end;
  12. KodeZwerg

    WM_CHANGEUISTATE

    How about check OS version at initialization to create a boolean that be used in handler? Silly work around just to answer 🙂 (SysUtils.Win32MajorVersion is what I would use) (TOSVersion.Major sorry I am sleepy)
  13. KodeZwerg

    WM_CHANGEUISTATE

    You might loose ability that parts are repainted correct. Like pressing alt-key and no underline/shortcut is drawn. Untested, just a guess by reading Msdn.
  14. KodeZwerg

    Inch representation format in TEdit like controls

    @emailx45 Sorry that I mentioned that a TEdit looks better. By reading complete thread again, he asked if new Delphi got native stuff to do. He already has its own component so i am out.
  15. KodeZwerg

    Inch representation format in TEdit like controls

    Nothing against above stuff. Another approach can be usage of TEdit, parse data on your own to get a float as result to work with. Should have a better look, but users must be told somewhere how to enter data that it works. I found this code by Andreas Rejbrand to getting you started.
  16. KodeZwerg

    Read ASCII file from URL like a file

    If server accept http request without SSL, you could use InternetReadFile() api. This way your executable stay slim. //Edit Header should be in WinInet. 4 things you need InternetOpen() InternetOpenUrl() InternetReadFile() InternetCloseHandle()
  17. KodeZwerg

    Enumerating Windows Sounds

    There might be a better way. You can enumerate over registry. HKEY_CURRENT_USER\AppEvents\Schemes Then you know wich sound belong to wich action. If I missunderstood question, I am sorry.
  18. KodeZwerg

    isFileInUSe

    I did thought such, thanks. If someone find it usefull, here is my modificated variant. function IsFileInUse(const FileName: string): Boolean; // found on Delphi-Praxis forum // code provided by Remy Lebeau // slightly modified by KodeZwerg // (now you will get "True" for files that need administrative rights or on write protected media) var hFile: THandle; Attr: DWORD; begin Result := False; SetLastError(ERROR_SUCCESS); Attr := GetFileAttributes(PChar(FileName)); if (Attr <> $FFFFFFFF) and (Attr and FILE_ATTRIBUTE_DIRECTORY <> 0) then Exit(False); // only continue if we can normalize attributes if SetFileAttributes(PChar(FileName), FILE_ATTRIBUTE_NORMAL) then begin hFile := CreateFile(PChar(FileName), GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); if (hfile <> INVALID_HANDLE_VALUE) then CloseHandle(hFile) else Result := (GetLastError() = ERROR_SHARING_VIOLATION); // restore original attributes SetFileAttributes(PChar(FileName), Attr); end else Result := True; end;
  19. KodeZwerg

    isFileInUSe

    Sorry to bring up this old topic but I do have a problem. On normal folders all works sweet. On Windows protected folders it fail. (Always return false.) Is there a way to make it compatible to work for protected folder content? (C:\Program Files\ is a protected folder for example.) My addition to above code was to add a SetFileAttributes call to try if FILE_ATTRIBUTE_NORMAL can be set. If it cannot, folder is protected. Now I run out of Ideas.
  20. KodeZwerg

    Difference between Pred and -1

    In that code statement it does not matter if Pred() or attached -1 will be used. Both do same but Pred() can do more than give back decremented number. Those types are supported: Characters, Non-floating number types, Enumeration types and Pointers Example: Character := Pred( Char( 'X' ) ); = W /edit It might be possible that on mass operations a -1 is faster than using Pred(). Not tested by myself but possible. (not for above example, when used inside loops)
  21. KodeZwerg

    Hook keyboard and mouse

    In my world this exactly is a logger. Sorry i cant help with such due possible missuse. My advice would be, try find out how "mame" save that information to read-it-back for your purposes.
  22. KodeZwerg

    Hook keyboard and mouse

    What do you mean by this? Hook like a logger or something that activates by proper combination of hotkey? Wich Platforms should be supported? Wich Delphi you do use?
  23. I appreciate your help! Your edit cleared the mist i saw, thankyou! The rest i sure will figure out, you lead me on the way to do and play with 😄
  24. KodeZwerg

    What is the fastest way to check if a file exists?

    Please exclude TestPIDL method out of DoJob method, it produce MemoryLeak and is slowest methode anyway.
  25. KodeZwerg

    What is the fastest way to check if a file exists?

    Please remove my crappy PIDL try, it cause MemoryLeak.
×