How do I create a file using ATL ASP COM?

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


     ts_out_handle = CreateFile((LPCTSTR)FileName,

     if (ts_out_handle == INVALID_HANDLE_VALUE)
          return S_FALSE;

     return S_OK;


Question by:Evaus

Accepted Solution

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

...::CreateFile(BSTR FileName) {

char *p;
p = OLE2T(FileName);

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

Expert Comment

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()'

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.…

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