Jump to content

PawelPepe

Members
  • Content Count

    23
  • Joined

  • Last visited

Posts posted by PawelPepe


  1. Hi,

    I got a problem with TListView and Data. It seems that I got memory leaks, because Data pointers are not released (if I understand it well).

    Let me show you what I do:

     

    Here is a simple TListView (LV_Data). I add few items to the list (Report Style) into 3 Columns.

     

    var
       i        : Integer;
       ListItem : TListItem;
       PObject  : PChar;
    
       for i := 0 to 3 do
          begin
             // Caption
             ListItem := AList.Items.Add;
             ListItem.Caption := 'My Caption' + '_' + Inttostr(i+1);
    
             // Language Name
             ListItem.SubItems.Add('Language' + '_' + Inttostr(i+1));
             // User Name
             ListItem.SubItems.Add('User Name' + '_' + Inttostr(i+1));
    
             // User Data Path
             PObject := StrAlloc(250);
             StrPCopy(PObject, 'PATH_TO_USER_DIRECTORY' + '_' + Inttostr(i+1));
             ListItem.Data := PObject;
          end;

     

    As you can see, I also add "hidden" data (in this example a path to directory, as string). I can use it in program, without displaying it to user in listview.

    I can read it in simple way (for examle, in ListView OnClick event:)

    var
    	sPath : string;
    
       if (LV_Data.Items.Count > 0) AND (LV_Data.ItemIndex <> -1) then
          begin
             sPath := StrPas(PChar(LV_Data.Items[LV_Data.ItemIndex].Data));
          end;

     

    Everything works very nice... but, when I close program, I see there are some memory leaks.

     

    ---------------------------
    Unexpected Memory Leak
    ---------------------------
    An unexpected memory leak has occurred. The unexpected small block leaks are:

    473 - 520 bytes: Unknown x 3

    ---------------------------
    OK   
    ---------------------------
     

     

    As far as I know, I have to free those List View Data bymyself. How to do this?

     

    procedure TMainFrm.LV_DataDeletion(Sender: TObject; Item: TListItem);
    begin
       if Item.Data <> nil then
          begin
             FreeMem(Item.Data);
             Item.Data := nil;
          end;
    end;

    Above code not working (why!?), got Invalid Pointer Operation.

     

    Could you please tell me how to free this data to avoid memory leak?

     

    Thank you in advance,

    -Pawel

     


  2. Yup, I am sure there are many different methods. I can not use any that need to pass login data (user name,password).

    It seems the one I have (unfortunatelly in c) is the simplest. 

     

    Ps: There is a simple way to do this without complication, just run explorer:

    ShellExecuteW(0, 'open', 'explorer.exe', PWideChar(AFileNameToRun), '', SW_SHOW);

    But, this can not send mail with default client... so the best is to run any app with normal user privileges.


  3. 2 hours ago, Der schöne Günther said:

    Just saying: Your source is just a copy from @Remy Lebeau's original post on https://stackoverflow.com/a/37949303

    @Der schöne Günther

    Did you read my post?

    No, my code is not a copy - this is C->Delphi translation. But, not working.

    I din't write original code! I made delphi code based on linked code. To be clear.

    -Pawel

     

    @DelphiUdIT

    Thanks, will check that out.


  4. Hi,

    Here is a problem. 
    I would like to run an application with normal user privileges from elevated process.
    My installer (elevated process) is written in Delphi. It launches some programs at the end of installation.
    Now, as Installer is elevated, lauched process is also elevated - we don't want this!

     

    The goal is to launch non-elevated process from elevated installer process. So:
    - Launch any application with normal user privileges
    - Launch default web browser with given webpage
    - Send email to given person (with protocol Sendto:)


    As far as I know it can be done using Windows Explorer process. I couldn't find any Delphi code for that in Internet 😞 I only found C- based.
    Here is one that suppose to work: https://www.appsloveworld.com/coding/delphi/48/createprocess-with-lower-privileges-than-the-caller

     

    Could you please try to convert it into Delphi?

     

    I tried, but without success (see below example).
    There are some problems with pointers (I tried to do pointers typecasting - it compiled, but with access violation)...

    For example: FindDesktopFolderView(IID_IShellView, spsv); --> FindDesktopFolderView(IID_IShellView, Pointer(spsv));
    I am sure, this is not a way I should do.

     

    Here is my code in simple project.
    Source: https://www.dropbox.com/s/6ndno59brgbn6l0/ExecAsUser.zip?dl=1

     


    Thanks in advance,
    -Pawel


  5. Hey,

    I would like to ask you guys for some help... I am using now Delphi Community Edition 11.3 with VCL Styles.

    I downloaded from GetIt Package Manager nice Windows 11 Dark Style (Windows11_Modern_Dark.vsf).

    I am trying to modify this to my taste... There are few problems...

     

    The question is:

    Why TLabel text (with font color = clWindowText) is painted with White color? I changed this color in Style file(*.vsf) into red (using Bitmap Style Designer)  (see the image).

     

    I know, I can disable styles for control (by removing seFont -> ExampleLabel.StyleElements :=  [seClient,seBorder] ) but I want to make it global, for all Tlabels controls (or any other using clWindowText).

    Is that a bug or am I doing something wrong? How to change controls text in vcl style?

    The style I am talking about uses White (#FFFFFF) color for text (I think it is to bright for Dark Mode, it should be something like #E7E9EA, for example)

     

    Hope, you can help.

    Thanks in advance.

     

    Styles.thumb.png.20f7c1a99abf8e8d577f3b65499e12af.png


  6. I need to make it clear.

    I could build any of my projects with Delphi Community Edition 10.4.2 before my environement broke. So it was legal and that was functional in free Delphi version.

    But, when I reinstalled Delphi CE (the same version) it saddenly do not let me use command line compiler! On the same license, the same delphi version and the same Windows installation.

    This is why I am asking what happended. This is why I requested Delphi CE 10.4.2 users (who can use command line compiler) to send me those file (dcc32.exe). How can it be illegal when Delphi CE is free (I do not sell my programs - it is my hobby). Btw, my dcc32270.dll library is 27.0.40680.4203

     

    -Pawel


  7. @rvk

    Thanks. I already checked it. I don't have compiler in such localization (and Delphi CE is 21.0 not 18.0).

    I also installed Delphi CE in virtual machine to test it (and it also can not compile via command line 😞 )

     

    Ps: My dcc32.exe is 22.5 kb. Maybe somone of you - who CAN compile project using command line can send me compiler exe?

    -Pawel


  8. Hey,

    I am using Delphi Community Edition 10.4.2. 

    It was working fine. Yesturday it stopped working - I couldn't build any x64 project. I got a message: "Unit 'Vcl.Dialogs' not found"

    I couldn't solve this issue. I reinstalled Delphi. Installation was successful. Problem was fixed. 

    However, I can not now use batch files to compile my projects using Command line:

    MSBuild.exe /t:Clean,Build /p:config=Release;DCC_BuildAllUnits=true /p:platform=Win64 "MyjProject.dproj"

     

    Delphi Compiler says: This version of the product does not support command line compiling.

     

    How is that possible? Before reinstallation of Delphi I could normally build any project using command line!

     

    Is is known issue? Maybe I am doing something wrong? Is that possible that new Community Edition Online Installer NOT let using command line compiler?

    How do you compile dproj projects using command line?

     

    Thanks for any tip.

    -Pawel

     

     


  9. I want to write some simple application (the app I've always dreamed of) that will show Football Chamionships (user can enter match results and app will show tables and some statistics).
    My problem is sorting groups in Chamionships Group Stage (Quatar 2022).

    As we know, there are 8 groups (A-H) with 4 Teams each. Lets focus on Group A.
    So, we have 4 teams: A1, A2, A3 and A4. ONLY 2 OF THEM CAN PLAY IN KNOCKOUT STAGE.
    How to know which one? Anyone of you solved such problem?

    FIFA says:
    The ranking of teams in the group stage is determined as follows:
    1. Points obtained in all group matches;
    2. Goal difference in all group matches;
    3. Number of goals scored in all group matches;
    4. Points obtained in the matches played between the teams in question;
    5. Goal difference in the matches played between the teams in question;
    6. Number of goals scored in the matches played between the teams in question;
    7. Fair play points in all group matches (only one deduction can be applied to a player in a single match):
       - Yellow card: −1 point;
       - Indirect red card (second yellow card): −3 points;
       - Direct red card: −4 points;
       - Yellow card and direct red card: −5 points;
    8. Drawing of lots.


    I need to cover 6 points (7 and 8 can be ignored for the moment).

    There are 6 matches in Group, each Team play with another from group.
    A1:A2 | A3:A4
    A1:A3 | A4:A2
    A4:A1 | A2:A3

    I have no idea how to sort teams with FIFA guidelines.

    Have you got any idea? How to cover all conditions in one sort function?

    Could you maybe write for me some code to show how to do this? 

     

    Ps: If this is to difficult/complex - how much many would it cost for you to write some simple solution for me?

    -Pawel

×