Solved

How do I create a file using ATL ASP COM?

Posted on 2001-07-17
2
246 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
2 Comments
 

Accepted Solution

by:
_ov earned 50 total points
Comment Utility
Try to add this code:

...::CreateFile(BSTR FileName) {

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

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

Expert Comment

by:jkr
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

772 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

11 Experts available now in Live!

Get 1:1 Help Now