Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I create a file using ATL ASP COM?

Posted on 2001-07-17
2
Medium Priority
?
269 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 200 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

876 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