Solved

How do I create a file using ATL ASP COM?

Posted on 2001-07-17
2
256 Views
Last Modified: 2013-11-25
I'm Trying to Create a Method that creates a file in an ATL ASP COM using C++.

Here is my code, but no file is created:

STDMETHODIMP CDV::Create_File(BSTR FileName)
{

     ts_out_handle = CreateFile((LPCTSTR)FileName,
          GENERIC_WRITE,
     0,
        NULL,
     CREATE_ALWAYS,
     FILE_ATTRIBUTE_NORMAL,
     NULL);

     if (ts_out_handle == INVALID_HANDLE_VALUE)
     {
          return S_FALSE;
     }

     return S_OK;
}


Thanks

Evaus
0
Comment
Question by:Evaus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
_ov earned 50 total points
ID: 6288883
Try to add this code:

...::CreateFile(BSTR FileName) {

USES_CONVERSION;
char *p;
p = OLE2T(FileName);

... CreateFile(p, ...)
0
 
LVL 86

Expert Comment

by:jkr
ID: 6291019
If UNICODE in general is OK for you, just use



    ts_out_handle = CreateFileW((LPCTSTR)FileName

Note the capital 'W', it refers to the UNICODE version of 'CreateFile()'
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert GUI app into console app for Win32 Env 5 140
White board coding practice 3 99
Windows ICD FFU Issue 4 107
Outlook 13 102
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

752 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