Jump to content

KodeZwerg

Members
  • Content Count

    290
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by KodeZwerg

  1. Equal how you try, it end in a workaround since you publish it with a "write" property.
  2. that i mean, and within your class-code just adjust "_status" to whatever you like. or implement and publish a private setter to adjust only by code not by property if you know what i mean. TMyObject = Class(TObject) strict private _status: String; private procedure mysetter(const AValue: string); public Property Status: String Read _status; End;
  3. Why not dont publish "Read" "Write" at all and access internal the used Variable?
  4. How about BCryptGenRandom from Windows Api? Is that random/quality enough for your needs @Tommi Prami ?
  5. KodeZwerg

    Delphi 5 Printing

    @Geoff88: ShellExecute(Application.Handle, PChar('print'), PChar('A:\Path\to\a\file\to\print.pdf'), PChar(''), nil, SW_HIDE); you can let windows handle everything with that. this would open whatever programm is associated to print that file. //edit if you want full control, customized-printing-in-delphi, here you find everything you need.
  6. good day, is someone willing to help me port those two c# snippets into working delphi (winapi/wininet) snippets please? the first one: var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Post, RequestUri = new Uri("https://yandextranslatezakutynskyv1.p.rapidapi.com/translate"), Headers = { { "x-rapidapi-key", "1234567890" }, { "x-rapidapi-host", "YandexTranslatezakutynskyV1.p.rapidapi.com" }, }, Content = new FormUrlEncodedContent(new Dictionary<string, string> { { "apiKey", "1234567890" }, { "lang", "de-en" }, { "text", "dieser text soll übersetzt werden" }, }), }; using (var response = await client.SendAsync(request)) { response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body); } and the second one: var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://systran-systran-platform-for-language-processing-v1.p.rapidapi.com/translation/text/translate?source=auto&target=en&input=dieser%20text%20soll%20%C3%BCbersetzt%20werden"), Headers = { { "x-rapidapi-key", "1234567890" }, { "x-rapidapi-host", "systran-systran-platform-for-language-processing-v1.p.rapidapi.com" }, }, }; using (var response = await client.SendAsync(request)) { response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body); } thank you in advance!
  7. KodeZwerg

    can you help me port c# code to winapi/wininet please?

    function Http_Get: string; const headerkey = 'x-rapidapi-key: 1234567890'; headerhost = 'x-rapidapi-host: systran-systran-platform-for-language-processing-v1.p.rapidapi.com'; var hInet: HINTERNET; hURL: HINTERNET; Buffer: array[0..1023] of AnsiChar; i, BufferLen: cardinal; begin result := ''; hInet := InternetOpen('', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); try hURL := InternetOpenUrl(hInet, PChar('https://systran-systran-platform-for-language-processing-v1.p.rapidapi.com/translation/text/translate?source=auto&target=en&input=dieser%20text%20soll%20%C3%BCbersetzt%20werden'), PChar(headerkey + headerhost), 0, INTERNET_FLAG_SECURE, 0); try repeat InternetReadFile(hURL, @Buffer, SizeOf(Buffer), BufferLen); if BufferLen = SizeOf(Buffer) then result := result + AnsiString(Buffer) else if BufferLen > 0 then for i := 0 to BufferLen - 1 do result := result + Buffer[i]; until BufferLen = 0; finally InternetCloseHandle(hURL); end; finally InternetCloseHandle(hInet); end; end; this works, i get result = {"message":"You are not subscribed to this API."} now the code for post... thank you @mvanrijnen but i like to try with wininet.
  8. KodeZwerg

    can you help me port c# code to winapi/wininet please?

    function Http_Get(const Server: string; const Resource: string; const key: string): string; const headerkey = 'x-rapidapi-key: '; headerhost = 'x-rapidapi-host: systran-systran-platform-for-language-processing-v1.p.rapidapi.com'; var hInet: HINTERNET; hURL: HINTERNET; Buffer: array[0..1023] of AnsiChar; i, BufferLen: cardinal; begin result := ''; hInet := InternetOpen('', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); try hURL := InternetOpenUrl(hInet, PChar('https://' + Server + Resource), {how to put header in here?}nil, 0, INTERNET_FLAG_SECURE , 0); try repeat InternetReadFile(hURL, @Buffer, SizeOf(Buffer), BufferLen); if BufferLen = SizeOf(Buffer) then result := result + AnsiString(Buffer) else if BufferLen > 0 then for i := 0 to BufferLen - 1 do result := result + Buffer[i]; until BufferLen = 0; finally InternetCloseHandle(hURL); end; finally InternetCloseHandle(hInet); end; end; i am somehow stuck... please need help
  9. KodeZwerg

    Install .apk via google drive

    Why not create one mail template and spread it out to those 10?
  10. KodeZwerg

    Omnithread examples Target Delphi Version

    {$IF CompilerVersion >= 23} {$DEFINE NameSpace} {$ELSE CompilerVersion} {$UNDEF NameSpace} {$IFEND CompilerVersion} unit ppb1; interface uses {$IFDEF NameSpace} Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.StdCtrls, Vcl.ExtCtrls, System.Threading, {$ELSE NameSpace} Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls, ExtCtrls, {$ENDIF NameSpace} Thats a more generic approach for namespace handling.
  11. KodeZwerg

    Download Images from a URL

    {$IFDEF MSWindows} // code that run when windows is used {$ENDIF MSWindows} i really thought that was your question, find out other methods.
  12. KodeZwerg

    Download Images from a URL

    for windows i would use winapi, like that oneliner: Result := URLMon.URLDownloadToFile(nil, PChar('http://www.somewhere.com/something.gif'), PChar('a:\local\file.ext'), 0, nil) = 0;
  13. Very possible that you run into a version conflict. Check used Delphi Indy version and use for that proper libraries. //tip To find out the location of the "good" library (on your development pc), download a tool like ProcessHacker, run your application, let it load libraries, open ProcessHacker, doubleclick on your process, switch to "Modules" tab, either move mouse over library or doubleclick library, both result in telling you location.
  14. KodeZwerg

    Learning Delphi

    1. Hire a freelancer that teach 2. udemy has good learning courses, not free but worth the invest. (a free solution can be youtube, with proper search input you get okay output) Mix of both should be best practice.
  15. KodeZwerg

    Parse PIDL from Name located on portable device

    strange activity you are performing. for myself havent tried it direct like you. if you like, you can try my FileShell tool on your device, it is basical a PIDL walker.
  16. KodeZwerg

    QueryPerformanceCounter precision

    if milliseconds are precice enough, two calls to Now and subratract like ms := MillisecondOfTheDay(SecondNow) - MillisecondOfTheDay(FirstNow); can do it?
  17. KodeZwerg

    Resource Hacker

    Great program, mighty helper, cool creator, easy handling. Very nice!
  18. KodeZwerg

    Reverse method walker

    Proxy = No. Browser = Opera has internal VPN turned on. External (Windows) VPN turned off. Turning Opera internal VPN to off state will redirect to @david_navigator site, @Uwe Raabe is a genius, in no way I would have thought about that. Excuse me please, my intention was just to help.
  19. KodeZwerg

    Reverse method walker

    This is what my Browser show by opening the link i posted. //edit Without being registered to that site sir.
  20. KodeZwerg

    Delphi 10.4 Portable

    You are welcome! (If this way is legal = I do not know, I am sorry!)
  21. KodeZwerg

    Delphi 10.4 Portable

    Excuse me Sir, I do not understand meaning of empty reply. If my tip aint good I feel sorry and will more think about it.
  22. KodeZwerg

    Reverse method walker

    Licensing
  23. KodeZwerg

    Application.MessageBox in multiples monitors

    Could you at least tell what solution was working well for you to enlighten others by reading your topic?
  24. KodeZwerg

    Application.MessageBox in multiples monitors

    var MyMsg: TForm; begin MyMsg := CreateMessageDialog('put Message in here...', mtCustom, [mbOK]); MyMsg.Position := poOwnerFormCenter; MyMsg.ShowModal; end; Easiest solution this might be?
×