Solved

DELETE TMP FILES

Posted on 2004-09-27
11
377 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
 
LVL 4

Expert Comment

by:DaveyEss
ID: 12167695
0
 
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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 50 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
A short article about a problem I had getting the GPS LocationListener working.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now