Solved

How do I create a file using ATL ASP COM?

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Issues with C++ Class 19 101
Windows ICD FFU Issue 4 61
Need some help with mailto 16 20
Indy 10 not Receiving UDP broadcast 3 22
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

828 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