Jump to content

Gregory Koehn

Members
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

0 Neutral

Technical Information

  • Delphi-Version
    Delphi 10.3 Rio
  1. Gregory Koehn

    Any GraphQL implementation out there?

    Source of this information... https://landgraf.dev/en/graphql-from-the-perspective-of-a-delphi-developer/ Oops! Sorry! The quote is about Swagger not GraphQL. Here is another link of Delphi GraphQL component... https://github.com/bogdanpolak/graphql-delphi Disclaimer. I have no experience with this component!
  2. Thanks for the info! I guess I was looking for something a bit more RAD and visual. For any new Delphi developer coming along, They may want to use the "type library editor". Does anyone have up-to-date tutorials regarding creating it in the "type library editor"? For example the Delphi Com Client code should be able to access it like... This is not actual syntactically correct code! Just here for illustration... uses ComObj ; procedure TForm1.Button1Click(Sender: TObject); var ComServer: OleVariant; Item: OleVariant; i : Integer; countOfItems: Integer; begin ComServer := CreateOleObject('ComServer.GregsComServer'); countOfItems := ComServer.Store.ItemsCount(); for i := 0 to countOfItems-1 do begin Item := ComServer.Store.Items(i); Showmessage(Item.Name); Showmessage(inttostr(Item.InStockCount)); end; ComServer := null; end; No need to waist time on me... Just if someone is bored and wants some ideas to publish an article about the RAD of Delphi...
  3. It would be great if someone would write a simple tutorial on Windows Com using Delphi 10.Latest! Maybe do a video and put it on YouTube. I would like to learn how to create a com object method that returns another com object. For example... Com Object Name = "Store" "Store" has a method that returns Com Object "Item". "Item" has a string property of "Name". "Item" has a int property of "InStockCount". I can't take the time right now to learn all this by going through pages and pages of internet sites that were written for Delphi 5. For now I will just put data into a string array and parse it in the consumer. What I am actually doing is wrapping a 32-bit DLL, provided by another company, in a Com Server, so we can access it by using our 64-bit program. You know how it is in real life... Get it done as soon as possible!!! I don't want you to do my work for me... It would be good info for future seekers to find and use!
  4. I got it to work!!! See ParameterDesign.png attached... You cannot send it as a result but as an "out" parameter! Here is my Server "Code Behind" of "Method2"... procedure TGregsComServer.Method2(out MyVariantArray: OleVariant); begin MyVariantArray := VarArrayCreate([0, 1], varOleStr); MyVariantArray[0] := 'Hello'; MyVariantArray[1] := 'World'; end; Here is my Delphi Consumer code now... procedure TForm1.Button2Click(Sender: TObject); var ComServer: OleVariant; vUDTArray: OleVariant; i : Integer; value : String; begin ComServer := CreateOleObject('ComServer.GregsComServer'); ComServer.Method2(vUDTArray); if VarIsArray(vUDTArray) then begin if VarIsByRef(vUDTArray) then ShowMessage('varisbyref'); for i := VarArrayLowBound(vUDTArray, 1) to VarArrayHighBound(vUDTArray, 1) do begin Value := vUDTArray[i]; ShowMessage(Value); end; end; ComServer := null; end; Thanks for your help Anders! Good to see you are still producing Delphi code!
  5. And here is my simple Delphi consumer... uses ComObj ; procedure TForm1.Button1Click(Sender: TObject); var ComServer: OleVariant; vUDTArray: OleVariant; i : Integer; value : String; begin ComServer := CreateOleObject('ComServer.GregsComServer'); vUDTArray := ComServer.Method1; if VarIsArray(vUDTArray) then begin if VarIsByRef(vUDTArray) then ShowMessage('varisbyref'); for i := VarArrayLowBound(vUDTArray, 1) to VarArrayHighBound(vUDTArray, 1) do begin Value := vUDTArray; ShowMessage(Value); end; end; ComServer := null; end; end.
  6. I just created a fresh ComServer project in Delphi 10.3. I did New | VCL Application Then did File | New | Other... | Individual Files | Automation Object See 1st-step.png Then Created a Method in the ridl editor like this... See 2nd-step.png Then registered it "Current User". See 3rd-step.png Complete code is in the attached zip file. When actually calling this method is when the error pops up. It only happens when calling it from a COM Client. Compilation works fine. How can I get this to work? It very well could be just a simple thing I am doing wrong... ComServerTest.zip
  7. Anders, Good to hear from you! Here is what Delphi gives me... See attached png file. I just can't get peoples examples on the internet to work when actually running it in Delphi IDE! Has the compiler changed? Does it have a bug?
  8. I just want to be able to assemble an array of string values and return them using COM automation to Python. I have been successful in returning an array of integers by using this code... function TGridInfo.GetIntArray: PSafeArray; var ArrayBounds : TSafeArrayBound; i : integer; ArrayData : pointer; lElemCount: integer; type IntegerArray = Array of integer; begin lElemCount := 11; ArrayBounds.lLbound := 0; ArrayBounds.cElements := lElemCount; result := SafeArrayCreate( varInteger, 1, @ArrayBounds ); if SafeArrayAccessData( result, ArrayData ) = S_OK then begin for i:= 0 to lElemCount-1 do begin IntegerArray(ArrayData)[i]:= i; end; SafeArrayUnAccessData(result); end; end; I then try to convert this to String Array... function TGridInfo.GetStringArray: PSafeArray; var ArrayBounds : TSafeArrayBound; i : integer; ArrayData : pointer; lElemCount: integer; type StringArray = Array of widestring; begin lElemCount := 11; ArrayBounds.lLbound := 0; ArrayBounds.cElements := lElemCount; result := SafeArrayCreate( VT_BSTR, 1, @ArrayBounds ); if SafeArrayAccessData( result, ArrayData ) = S_OK then begin for i:= 0 to lElemCount-1 do begin StringArray(ArrayData)[i]:= 'element ' + inttostr(i); end; SafeArrayUnAccessData(result); end; end; This returns some strange numbers to Python instead of strings. This also returns strange numbers to Delphi instead of strings. Here is my Delphi reading code... implementation {$R *.dfm} uses ComObj ; procedure TForm1.Button1Click(Sender: TObject); var ComServer: OleVariant; vUDTArray: OleVariant; i : Integer; value : String; begin ComServer := CreateOleObject('Project1.GridInfo'); vUDTArray := ComServer.GetStringArray; if VarIsArray(vUDTArray) then begin for i := VarArrayLowBound(vUDTArray, 1) to VarArrayHighBound(vUDTArray, 1) do begin Value := vUDTArray[i]; ShowMessage(Value); end; end; ComServer := null; end; end.
  9. Help me out! I cannot get this figured out. function TGridInfo.Method4: OleVariant; var I: integer; ListItemCount: integer; gklist: tstringlist; V: OleVariant; begin gklist := tstringlist.Create; try gklist.Add('hello'); gklist.Add('world'); ListItemCount := gklist.Count; //V := VarArrayCreate([0,ListItemCount-1], VT_BSTR); //<-- This does not work gives error on result := V; //V := VarArrayCreate([0,ListItemCount-1], VT_LPWSTR); //<-- errors here. V := VarArrayCreate([0,ListItemCount-1], varVariant); //<-- This does not work either gives error on result := V; for I := 0 to ListItemCount-1 do V[I]:=gklist[I]; result := V; finally gklist.Free; end; end; I am using Delphi 10.3. Notice my comments in source code as to the problems I have been having. I am using Python 3.8 to test this system from win32com import client com_object = client.Dispatch("Project1.GridInfo") res = com_object.Method4() print(res) com_object = None
×