Improve company productivity with a Business Account.Sign Up

x
?
Solved

DELETE TMP FILES

Posted on 2004-09-27
11
Medium Priority
?
441 Views
Last Modified: 2008-02-20
heya

i would like to know,

what is the easiest and most efficient  i.e. best ;)   way to delete my tmp files after im done with them.

btw:
the tmp files r created using GetTempFileName()


Any help would be much appreciated,
suma
0
Comment
Question by:suma_ds
  • 3
  • 3
  • 2
  • +3
11 Comments
 
LVL 3

Expert Comment

by:domj
ID: 12166161
what language/environment?
0
 
LVL 6

Expert Comment

by:SCDMETA
ID: 12166392
Windows API CreateFile has a flag FILE_FLAG_DELETE_ON_CLOSE.  
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/createfile.asp
0
 
LVL 1

Author Comment

by:suma_ds
ID: 12166549
domj:
non-managed win32 c++, designed for windows XP/2000

SCDMETA:
unfortunately i am not using CreateFile.
i just use GetTempFileName to get a random file name, and then open it using the "fstream.h" class
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
LVL 1

Expert Comment

by:shankar_ms
ID: 12172795
Use "SHFileOperation" ...
"GetTempPath" gives the temp path, using temp path and SHFileOperation you can cleanup the temp dir

SH
0
 

Expert Comment

by:int__main
ID: 12176493
DaveyEss: i need a method that will work even if the file is open/in use by another process, and remove() dosnt do this. my bad, i really should have put more detailed specs in the question.



shankar_ms:

i dont think ima be using that method any time soon lol

compiling this code:

#include "shellapi.h"
#pragma comment (lib, "shell32.lib")

produces:

c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(68): error C2059: syntax error : ')'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(69): error C2059: syntax error : ')'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(55): error C2065: 'HDROP' : undeclared identifier
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(66): error C2065: 'HWND' : undeclared identifier
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(64): error C2065: 'LPPOINT' : undeclared identifier
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57): error C2065: 'LPSTR' : undeclared identifier
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(58): error C2065: 'LPWSTR' : undeclared identifier
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57): error C2078: too many initializers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(58): error C2078: too many initializers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(64): error C2078: too many initializers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(66): error C2078: too many initializers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(58): error C2086: 'int DECLSPEC_IMPORT' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'DECLSPEC_IMPORT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(64): error C2086: 'int DECLSPEC_IMPORT' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'DECLSPEC_IMPORT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(65): error C2086: 'int DECLSPEC_IMPORT' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'DECLSPEC_IMPORT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(66): error C2086: 'int DECLSPEC_IMPORT' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'DECLSPEC_IMPORT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(68): error C2086: 'int DECLSPEC_IMPORT' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'DECLSPEC_IMPORT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(69): error C2086: 'int DECLSPEC_IMPORT' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'DECLSPEC_IMPORT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(75): error C2086: 'int DECLSPEC_IMPORT' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'DECLSPEC_IMPORT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(58): error C2086: 'int EXTERN_C' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'EXTERN_C'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(64): error C2086: 'int EXTERN_C' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'EXTERN_C'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(65): error C2086: 'int EXTERN_C' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'EXTERN_C'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(66): error C2086: 'int EXTERN_C' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'EXTERN_C'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(68): error C2086: 'int EXTERN_C' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'EXTERN_C'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(69): error C2086: 'int EXTERN_C' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'EXTERN_C'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(75): error C2086: 'int EXTERN_C' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'EXTERN_C'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(69): error C2086: 'int HINSTANCE' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(68) : see declaration of 'HINSTANCE'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(58): error C2086: 'int STDAPICALLTYPE' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'STDAPICALLTYPE'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(64): error C2086: 'int STDAPICALLTYPE' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'STDAPICALLTYPE'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(65): error C2086: 'int STDAPICALLTYPE' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'STDAPICALLTYPE'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(66): error C2086: 'int STDAPICALLTYPE' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'STDAPICALLTYPE'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(68): error C2086: 'int STDAPICALLTYPE' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'STDAPICALLTYPE'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(69): error C2086: 'int STDAPICALLTYPE' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'STDAPICALLTYPE'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(58): error C2086: 'int UINT' : redefinition
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57) : see declaration of 'UINT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(65): error C2144: syntax error : 'void' should be preceded by ';'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(66): error C2144: syntax error : 'void' should be preceded by ';'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(68): error C2146: syntax error : missing ')' before identifier 'hwnd'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(69): error C2146: syntax error : missing ')' before identifier 'hwnd'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(64): error C2146: syntax error : missing ';' before identifier 'BOOL'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57): error C2146: syntax error : missing ';' before identifier 'DECLSPEC_IMPORT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(58): error C2146: syntax error : missing ';' before identifier 'DECLSPEC_IMPORT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(64): error C2146: syntax error : missing ';' before identifier 'DECLSPEC_IMPORT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(65): error C2146: syntax error : missing ';' before identifier 'DECLSPEC_IMPORT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(66): error C2146: syntax error : missing ';' before identifier 'DECLSPEC_IMPORT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(68): error C2146: syntax error : missing ';' before identifier 'DECLSPEC_IMPORT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(69): error C2146: syntax error : missing ';' before identifier 'DECLSPEC_IMPORT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(75): error C2146: syntax error : missing ';' before identifier 'DECLSPEC_IMPORT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(66): error C2146: syntax error : missing ';' before identifier 'DragAcceptFiles'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(65): error C2146: syntax error : missing ';' before identifier 'DragFinish'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57): error C2146: syntax error : missing ';' before identifier 'DragQueryFileA'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(58): error C2146: syntax error : missing ';' before identifier 'DragQueryFileW'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(64): error C2146: syntax error : missing ';' before identifier 'DragQueryPoint'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(68): error C2146: syntax error : missing ';' before identifier 'HINSTANCE'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(69): error C2146: syntax error : missing ';' before identifier 'HINSTANCE'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(75): error C2146: syntax error : missing ';' before identifier 'HINSTANCE'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(68): error C2146: syntax error : missing ';' before identifier 'ShellExecuteA'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(69): error C2146: syntax error : missing ';' before identifier 'ShellExecuteW'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57): error C2146: syntax error : missing ';' before identifier 'STDAPICALLTYPE'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(58): error C2146: syntax error : missing ';' before identifier 'STDAPICALLTYPE'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(64): error C2146: syntax error : missing ';' before identifier 'STDAPICALLTYPE'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(68): error C2146: syntax error : missing ';' before identifier 'STDAPICALLTYPE'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(69): error C2146: syntax error : missing ';' before identifier 'STDAPICALLTYPE'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(75): error C2146: syntax error : missing ';' before identifier 'STDAPICALLTYPE'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57): error C2146: syntax error : missing ';' before identifier 'UINT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(58): error C2146: syntax error : missing ';' before identifier 'UINT'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(65): error C2182: 'STDAPICALLTYPE' : illegal use of type 'void'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(66): error C2182: 'STDAPICALLTYPE' : illegal use of type 'void'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(64): error C2501: 'BOOL' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(55): error C2501: 'DECLARE_HANDLE' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57): error C2501: 'DECLSPEC_IMPORT' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(58): error C2501: 'DECLSPEC_IMPORT' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(64): error C2501: 'DECLSPEC_IMPORT' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(65): error C2501: 'DECLSPEC_IMPORT' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(66): error C2501: 'DECLSPEC_IMPORT' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(68): error C2501: 'DECLSPEC_IMPORT' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(69): error C2501: 'DECLSPEC_IMPORT' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(75): error C2501: 'DECLSPEC_IMPORT' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(66): error C2501: 'DragAcceptFiles' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(65): error C2501: 'DragFinish' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57): error C2501: 'DragQueryFileA' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(58): error C2501: 'DragQueryFileW' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(64): error C2501: 'DragQueryPoint' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57): error C2501: 'EXTERN_C' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(58): error C2501: 'EXTERN_C' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(64): error C2501: 'EXTERN_C' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(65): error C2501: 'EXTERN_C' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(66): error C2501: 'EXTERN_C' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(68): error C2501: 'EXTERN_C' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(69): error C2501: 'EXTERN_C' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(75): error C2501: 'EXTERN_C' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(68): error C2501: 'HINSTANCE' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(69): error C2501: 'HINSTANCE' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(75): error C2501: 'HINSTANCE' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(68): error C2501: 'ShellExecuteA' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(69): error C2501: 'ShellExecuteW' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57): error C2501: 'STDAPICALLTYPE' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(58): error C2501: 'STDAPICALLTYPE' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(64): error C2501: 'STDAPICALLTYPE' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(68): error C2501: 'STDAPICALLTYPE' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(69): error C2501: 'STDAPICALLTYPE' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(57): error C2501: 'UINT' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(58): error C2501: 'UINT' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\ShellAPI.h(75): fatal error C1003: error count exceeds 100; stopping compilation
0
 
LVL 1

Expert Comment

by:shankar_ms
ID: 12181981
Dont use "stdafx.h" in the header file. Use windows.h and and other releated headers and make the cpp file containing "shell API" calls to have the option "Not using pre compiled header".

SH
0
 
LVL 1

Author Comment

by:suma_ds
ID: 12187111
ahhh that's better... dam i think that's the first time ive ever got more than 100 errors X)

well anywayz i tested it out using this code:

      char TempPath[2048];
      GetTempPath(2048, TempPath);

      std::string d = TempPath;
      d += "*.*";

      SHFILEOPSTRUCT s;

      s.hwnd = NULL;
      s.wFunc = FO_DELETE;
      s.pFrom  = d.c_str();
      s.pTo = NULL;
      s.fFlags = FOF_SILENT;
      s.fAnyOperationsAborted = NULL;
      s.hNameMappings = NULL;
      s.lpszProgressTitle = NULL;

      SHFileOperation(& s);

but nuttin happened... can u give me any advice on how to make the above code work?

thankz,
suma
0
 
LVL 4

Expert Comment

by:DaveyEss
ID: 12193991
I don't think you can delete a file that is in use.  The following link however gives some more examples  on how to delete files

http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_21036895.html
0
 
LVL 1

Accepted Solution

by:
shankar_ms earned 200 total points
ID: 12195490
s.PFrom needs a double terminated string. Instead of
s.pFrom  = d.c_str();
do something like
TCHAR pFrom[MAX_PATH];
memset(pFrom,0,MAX_PATH);
_tcscpy(pFrom,d.c_str());
s.pFrom  = pFrom;

Aslo note that, do not use "d += "*.*"; because you might not have permission delete all the dir under temp.
Since you are using GetTempFileName(...) you will know the prefix of the files that you are creating. For example if my prefix is "tmp" then
use "d += "tmp*.*";

Based on your example here is the code

 TCHAR TempPath[MAX_PATH];
 memset(TempPath,0,MAX_PATH);
  GetTempPath(MAX_PATH, TempPath);
    std::string d = TempPath;
    d += "tmp*.*";
    TCHAR pFrom[MAX_PATH];
    memset(pFrom,0,MAX_PATH);
   _tcscpy(pFrom,d.c_str());
      
     SHFILEOPSTRUCT s;

     s.hwnd = NULL;
     s.wFunc = FO_DELETE;
     s.pFrom  = pFrom;
     s.pTo = NULL;
     s.fFlags =  FOF_NOCONFIRMATION  | FOF_SILENT;
     s.fAnyOperationsAborted = FALSE;
     s.hNameMappings = NULL;
     s.lpszProgressTitle = NULL;

     SHFileOperation(&s);



-Sh
0
 
LVL 1

Author Comment

by:suma_ds
ID: 12197517
thanks :)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Introduction to Processes

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question