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 7429025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:54:15+00:00 2026-05-29T08:54:15+00:00

I was having a problem with using SHFileOperation : SHFileOperation/SHFILEOPSTRUCT . I got that

  • 0

I was having a problem with using SHFileOperation: SHFileOperation/SHFILEOPSTRUCT. I got that working but I am now trying to put that into a function as it will be used several times throughout my code. The functions is:

void SHFileOperationFunc(string item1, string item2, int operation)
{
    SHFILEOPSTRUCT sf;
    memset(&sf,0,sizeof(sf));
    sf.hwnd = 0;
    sf.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI;

    switch(operation)
    {
    case 1:

    case 2:
        sf.wFunc = FO_COPY;
        string files = item1 + "\\*.*";
        files.append(1, '\0');
        sf.pFrom = files.c_str();
        item2.append(1, '\0');
        sf.pTo = item2.c_str();
    }

    int opOkay = SHFileOperation(&sf);
    if(opOkay != 0)
    {
        //FAIL
    }

}

When I had the code outside the function it worked fine. But now that it is as above i get an error returned to opOkay. The error value is 124 which means ERROR_INVALID_LEVEL – The system call level is not correct. I dont know what this means. Google hasnt been much help either. Anyone enlighten me?

Also should i be using SHFileOperation at all or should I be using IFileOperation?

Cheers.

  • 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-29T08:54:15+00:00Added an answer on May 29, 2026 at 8:54 am

    The problem is that files will go out of scope when the switch block ends and sf.pFrom will be a dangling pointer. Move declaration of files to outside of the switch.

    Note you have no breaks in either of the switch blocks.

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

Sidebar

Related Questions

I'm trying to wrap div with specific html code but I'm having problem using
I'm having a problem using the java.text.MessageFormat object. I'm trying to create SQL insert
I am having a strange problem when using this XML-to-NSDictionary class.really it was working
I am having some problem using the clone function in jQuery. I have been
I'm having a problem using SQLAlchemy with PySide(PyQt). I'm trying to pop-up a QtGui.QDialog
I'm having a problem using WCF Data Services for an entity that has a
I'm new to jquery and having a problem using .delegate() to bind a function
I'm having a problem using Make's wildcard function in my Android.mk build file. My
Im having a problem using an isNumeric jQuery function to check if a variable
i'm having a problem using stricmp in a specific function, in other functions 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.