Jump to content

msd

Members
  • Content Count

    68
  • Joined

  • Last visited

Everything posted by msd

  1. msd

    Delphi 11.1 - High DPI

    Hello Uwe, Delphi is not a problem; it works fine. The problem is compiled applications and distributed on computers with high-DPI screens. I need to solve deployed applications... Thanks anyway for the advice.
  2. Hello, I have a class which is a representation of some API communication with a REST server and that class has methods that exchange data with the server. Because this class has communication with REST, I can't wait for every response and I would like to add threat functionality to this class. My idea is that when I call the create method of my class, it will start in a separate thread and the whole class will work in its own thread and every method call to this class will be async. The response class (thread in class) informs the main thread that it contains some data and the app can use it. Thanks for the tips and advices in advance...
  3. Hello, I made my custom solution and I got the hardware fingerprint I wanted (for example, 1805-AD75-1308-150F) and it is definitely unique because I'm using 3-5 hardware components when I plan to generate this fingerprint. This is a similar solution to popular DLL components, which return some code to represent a unique hardware id, but in my dev factory. Thank you for all of the professional responses and information:-)
  4. Hello, We need to create an XML document file for an online document exchange system, and that XML file must include attachments. I can show you how it appears, but I'm not sure how to add/encode documents into a string that will be used to represent documents in an XML file (like attachment). In other words, how to encode a file into a string that may be used to represent it in an XML structure. Thank you very much...
  5. I was made function that works the job 🙂 if someone need it... function EncodePDF(const AFileName: string): string; var inStream: TStream; outStream: TStringStream; begin inStream := TFileStream.Create(AFileName, fmOpenRead); try outStream := TStringStream.Create; try TNetEncoding.Base64.Encode(inStream, outStream); finally Result := outStream.DataString; outStream.Free; end; finally inStream.Free; end; end; if someone has better idea, please post it here 😉
  6. This is a link: https://base64.guru/converter/encode/pdf where you can find how to encode PDF and the correct way to add it to XML. This link was given to us by the developer, and when we use this online tool and generate an XML tag, everything works fine:-) It looks like a simple Base64 encode from Delphi is OK, so if you can give me a sample (only encode/decode part of code).
  7. Because I only work on the client side, I have no experience with server-side encoding. I'm aware that the documentation specifies that nodes with attachments must be document/pdf in binary format. My initial question was about how to convert PDF files to binary and then put it into XML. I'll try Base64 Encoding first, and if it works, I'll put a bit of code here for the other members to see. Thank you for your suggestions...
  8. I wrote that this is a universal doc exchange web app. I'm from the client side. I need to push XML to the web app in XML format with an embedded PDF document.
  9. Hello, This is an example from an existing document... <cbc:EmbeddedDocumentBinaryObject mimeCode="application/pdf" filename="document_name.pdf">JVBERi0xLjcNCiW.....EmbeddedDocumentBinaryObject> This is a universal app, so there is no specific need for some encoding or decoding, just a simple representation of the binary representation of the document...
  10. msd

    Hardware ID

    Hello, I'm working now on Latest RAD Studio and I version incompatibility of my source which is generating some unique HardwareID function InternalGetHardwareID(Hdd: AnsiChar): AnsiString; var pdw: pDWord; mc, fl: dword; ID_1: AnsiString; ID_1L: dword; ID_2: Cardinal; ID_3: Cardinal; ID_5: AnsiString; CPUID: TCPUID; I: Integer; AddOn: Longword; TempStr: AnsiString; TempByte: Byte; Index: Integer; FUniqueID: AnsiString; begin Result := ''; FUniqueID := '{61AF17B9-4EDB-4849-93CD-113C14E139F7}'; try New(pdw); GetVolumeInformation(PChar(Hdd + ':'), nil, 0, pdw, mc, fl, nil, 0); ID_1L := pdw^; ID_1 := IntToHex(pdw^, 8); Dispose(pdw); except exit; end; for I := Low(CPUID) to High(CPUID) do CPUID[I] := -1; if IsCPUIDAvailable then begin CPUID := GetCPUID; ID_2 := CPUID[1] + CPUID[2] + CPUID[3] + CPUID[4]; // First chance exception at $7631ED42. Exception class EIntOverflow with message 'Integer overflow' ID_3 := (CPUID[1] shr 12 and 3) * (CPUID[1] shr 8 and $F) * (CPUID[1] shr 4 and $F) * (CPUID[1] and $F); ID_5 := GetCPUVendor; {$WARNINGS OFF} AddOn := Longword(ID_1L + ID_2 * ID_3); for I := 1 to Length(ID_5) do AddOn := (AddOn xor Ord(ID_5[I])); TempStr := IntToHex(AddOn, 8); Index := 1; for I := 1 to Length(TempStr) do begin {$R-} TempByte := ((Ord(TempStr[I]) xor (AddOn div I)) + Ord(ID_1[I])) div 5; {$R+} {$WARNINGS ON} if poUniqueHardwareID in Options then // This is error line begin TempByte := Ord(FUniqueID[Index]) xor TempByte; Inc(Index); if Index > Length(FUniqueID) then Index := 1; end; Result := Result + IntToHex(TempByte, 2); end; if Length(Result) > 16 then Result := Copy(Result, 1, 16); if Length(Result) < 16 then for I := Length(Result) + 1 to 16 do Result := '0' + Result; end else begin if Assigned(FOnUnknownHardware) then FOnUnknownHardware(Self); // This is error line end; end;
  11. Hello, I have a little bit specific situation with one web service, It receives HTTP requests over the HTTP 1.0 protocol but the problem is when TransferEncoding is Chunked. Can I force TidHTTP not to send TransferEncoding is Chunked? I try with HTTPClient.Request.TransferEncoding := 'gzip, deflate, br'; but I get chunked on the webserver side.
  12. Hello Angus, Could you please, if you have little free time, put here some sample pieces of source code for posting data / JSON in a way that you were described with ICS? Thanks for any assistance and support in advance...
  13. Hello, I found that Delphi has a nice classes for JSON objects TJsonTextReader & TJsonTextWriter and I have one quesion for the TJsonTextReader. How to extract only search node from bottom JSON sample (or columns node or colors node, I need only one node for processing out of whole JSON) { "columns":[ { "column":"AccountID", "caption":"Account", "width":"100" }, { "column":"Name", "caption":"Account Name", "width":"250" }, { "column":"IsActive", "caption":"A", "width":"30" } ], "search":[ { "column":"Account", "rules":"Asc" }, { "column":"Name", "rules":"Asc;Part" } ], "colors":[ { "column":"Account", "rules":"Red;White" }, { "column":"Name", "rules":"Blue;Black" } ] } Thanks for the help and assistance in the advance 🙂
  14. Hello Remy Lebeau, Two very good ideas :-) I plan to use JsonReader because of memory usage and it is fresh tech in RAD Studio, but you give me very good tip. Thanks once again for the all advices...
  15. Hello Developers. I have one simple but not so simple in programming way of thinking request. I need to set up some applications with web service for prepaid ticketing sales. For example, a customer buys a ticket for some services and that ticket is inactive at that moment. After few days customer wants to activate this ticket and use the service that was subject of that ticket (for example, the ticket offers 3 days of free gaming in the gaming center with 5 locations). And after he activates his ticket web server needs to know which ticket was activated and to tell all other clients with some event which will be recognized by all clients at the moment of activating that that ticket is active for 3 days from today at some time. I plan to build web service which will be the center point of the app, and when operator sells ticket web service register customer data and with some event, which is listened by all Delphi App clients mark that ticket as available for activating on the any Delphi client app. After activating the Delphi app send the number, date, and time of the activated ticket to web service and web service with some event tell all clients that data. I know that this was simple every time users want to use a ticket Delphi app can contact web service, but users need an offline security system, so every client must know everything about tickets... Scenario: User buy a ticket at gaming location 3, operator fill form and with API mark ticket as sold on the web app, user want to activate this ticket after one week in the gaming location 5, user read QR code and send activating request by API to the web app and the main point of this flow is that at this moment web app fire some event which will be available for all Delphi app to mark time and date of the activated ticket in local DB. I need some expert advice 🙂 Thanks for all advice, assistance, and help in the advance...
  16. Hello developers, I need small expert assistance for translating old TIdHTTP requests to new TNetHTTPRequest. I have one function for Get and one function for Post, but credentials in the header do not have the same logic, and if someone can translate it to a new TNetHTTPRequest way of web service connection? function appGetData(API): boolean; var Url: string; lHTTP: TIdHTTP; xml: IXMLDocument; XmlRS, HttpRS, HttpRC: string; begin HttpRC := ''; HttpRS := ''; if Port = '' then Url := dm.apiHttp + '://' + dm.Server + '/api' + API else Url := dm.apiHttp + '://' + dm.Server + ':' + dm.Port + '/api' + API; try lHTTP := TIdHTTP.Create; try lHTTP.Request.Clear; lHTTP.Request.BasicAuthentication := true; lHTTP.Request.Accept := 'application/xml'; lHTTP.Request.UserName := dm.UserName; lHTTP.Request.Password := dm.Password; lHTTP.Request.ContentEncoding := 'utf-8'; lHTTP.Request.UserAgent := 'Mozilla/3.0 (compatible; Indy Library)'; lHTTP.Request.CustomHeaders.AddValue('OrganisationId', dm.Company); lHTTP.Request.CustomHeaders.AddValue('Accept', 'application/xml'); lHTTP.HTTPOptions := [hoForceEncodeParams]; XmlRS := lHTTP.Get(Url); HttpRC := IntToStr(lHTTP.ResponseCode); HttpRS := lHTTP.ResponseText; except end; lHTTP.Free; if HttpRC = '200' then Result := true else Result := false; finally end; end; function PostData(API, xml: string): boolean; var Url: string; lHTTP: TIdHTTP; XmlData: TStringStream; XmlRS, HttpRS, HttpRC: string; begin HttpRC := ''; HttpRS := ''; XmlData := TStringStream.Create(xml); if Port = '' then Url := dm.apiHttp + '://' + Server + '/api' + API else Url := dm.apiHttp + '://' + Server + ':' + Port + '/api' + API; try lHTTP := TIdHTTP.Create; try lHTTP.Request.Clear; lHTTP.Request.BasicAuthentication := true; lHTTP.Request.Accept := 'application/xml'; lHTTP.Request.ContentType := 'application/xml'; lHTTP.Request.UserName := dm.UserName; lHTTP.Request.Password := dm.Password; lHTTP.Request.ContentEncoding := 'utf-8'; lHTTP.Request.UserAgent := 'Mozilla/3.0 (compatible; Indy Library)'; lHTTP.Request.CustomHeaders.AddValue('OrganisationId', dm.Company); lHTTP.Request.CustomHeaders.AddValue('Accept', 'application/xml'); lHTTP.HTTPOptions := [hoForceEncodeParams]; XmlRS := lHTTP.Post(Url, XmlData); HttpRC := IntToStr(lHTTP.ResponseCode); HttpRS := lHTTP.ResponseText; except end; XmlData.Free; lHTTP.Free; if HttpRC = '200' then Result := true else Result := false; finally end; end; Thanks for any help in the advance :-)
  17. Hello Amit, It works fine, thank you for a assistance :-)
  18. Hello Remy, I need some code rewritten to use HTTPClient & HTTPRequest instead of IdHTTP. Just someone need to translate my code (my functions) if he has some minutes free 🙂
×