Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Please help save my sanity...

Please help save my sanity...

Scheduled Pinned Locked Moved The Lounge
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I am writing a small program in C++ without MFC(call me a glutton for punishment, but I want to avoid the hassle of the dependancy). The premise of the program is that it will delete all of the files in a given directory if the file is older than a given number of days. 99% of the application works fine, except the code below: FILETIME ft; ULONGLONG qwResult; ft = getTimeInFiletime(); //ULONGLONG localAge = (ULONGLONG)age; // Copy the time into a quadword. qwResult = (((ULONGLONG) ft.dwHighDateTime) << 32) + ft.dwLowDateTime; // Subtract x days. ULONGLONG lngDaysToSubtract; lngDaysToSubtract = age* _DAY; qwResult -= lngDaysToSubtract; // Copy the result back into the FILETIME structure. ft.dwLowDateTime = (DWORD) (qwResult & 0xFFFFFFFF ); ft.dwHighDateTime = (DWORD) (qwResult >> 32 ); This code is creating a FILETIME structure that will contain the "cuttof date", for example if someone calls the program with a parameter of 30 days, it will create a FILETIME structure containing the date of 30 days ago. The problem here is this line: lngDaysToSubtract = age* _DAY; "age" is an int parameter passed into this function. If I replace this variable with a hard-coded parameter, say 30, this code works fine. But it fails if I use the function parameter. If I throw in a "printf("Age is: %s\n",age);", it shows that the value is what I expect it to be. I have been banging my head on this problem all morning. If anyone can help me solve it, I would be extremely grateful!! Thanks

    A 1 Reply Last reply
    0
    • L Lost User

      I am writing a small program in C++ without MFC(call me a glutton for punishment, but I want to avoid the hassle of the dependancy). The premise of the program is that it will delete all of the files in a given directory if the file is older than a given number of days. 99% of the application works fine, except the code below: FILETIME ft; ULONGLONG qwResult; ft = getTimeInFiletime(); //ULONGLONG localAge = (ULONGLONG)age; // Copy the time into a quadword. qwResult = (((ULONGLONG) ft.dwHighDateTime) << 32) + ft.dwLowDateTime; // Subtract x days. ULONGLONG lngDaysToSubtract; lngDaysToSubtract = age* _DAY; qwResult -= lngDaysToSubtract; // Copy the result back into the FILETIME structure. ft.dwLowDateTime = (DWORD) (qwResult & 0xFFFFFFFF ); ft.dwHighDateTime = (DWORD) (qwResult >> 32 ); This code is creating a FILETIME structure that will contain the "cuttof date", for example if someone calls the program with a parameter of 30 days, it will create a FILETIME structure containing the date of 30 days ago. The problem here is this line: lngDaysToSubtract = age* _DAY; "age" is an int parameter passed into this function. If I replace this variable with a hard-coded parameter, say 30, this code works fine. But it fails if I use the function parameter. If I throw in a "printf("Age is: %s\n",age);", it shows that the value is what I expect it to be. I have been banging my head on this problem all morning. If anyone can help me solve it, I would be extremely grateful!! Thanks

      A Offline
      A Offline
      AlexMarbus
      wrote on last edited by
      #2

      Not the right place to post a code-related topic. Maybe 'age' is not the problem, but _DAY is. Try: int iDay(_DAY); lngDaysToSubtract = age * iDay; -- Alex Marbus www.marbus.net

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups