Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6025835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:21:28+00:00 2026-05-23T04:21:28+00:00

I cannot delete files to Recycle Bin. VAR SHFileOpStruct: TSHFileOpStruct; begin with SHFileOpStruct do

  • 0

I cannot delete files to Recycle Bin.

VAR SHFileOpStruct: TSHFileOpStruct;
begin   
  with SHFileOpStruct  do
  begin
    wnd   := Handle; 
    wFunc := FO_DELETE;
    pFrom := PChar(FileName);
    fFlags:= 0;
    pTo   := NIL;
    hNameMappings:= NIL;
    lpszProgressTitle:= NIL;
  end;
  Result:= SHFileOperation(SHFileOpStruct); 
end;

I can delete files in this format: ‘1.xyz’ but not in this format ’12.xyz’ (file name is longer than 1 character).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:21:29+00:00Added an answer on May 23, 2026 at 4:21 am

    According to the documentation of SHFileOperation you should not use GetLastError to see if the operation succeeds. Check the Result of the function and use the documentation to figure out the error it returns. That should give you a better clue what the problem is.

    EDIT:

    Best guess from reading the documentation:

    pFrom

    Although this member is declared as a
    single null-terminated string, it is
    actually a buffer that can hold
    multiple null-delimited file names.
    Each file name is terminated by a
    single NULL character. The last file
    name is terminated with a double NULL
    character (“\0\0”) to indicate the end
    of the buffer

    So you should make sure pFrom is ended with a double 0. Try the following

    pFrom := PChar(FileName + #0);
    

    Also, what Delphi version are you using?

    EDIT2:

    Also make sure the structure is properly initialized to 0. Uncomment the FillChar

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application users cannot truly delete records. Rather, the record's Deleted field gets
i know how to delete records for jqgrid, but i realise i cannot select
I'm trying to delete files created by current user when he/she clicks logout button
I'd like to delete all the files in a given directory on a remote
I need to delete the same line in a large number of text files.
Does anyone know how to delete all files in a directory with Ruby. My
I would like to delete all files that are less than a specific size
I want to delete all lines from old log files and keep fresh 50
I am trying to use forfiles to delete files that are older than 7
I try to delete files from a directory I specify. The first time it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.