Login Page - Create Account

Support Board


Date/Time: Sat, 10 May 2025 21:18:19 +0000



CreateFile Compile Error

View Count: 777

[2016-05-22 18:00:03]
User892558 - Posts: 5
I've created my own C++ project in VS 2010 Premium following the instructions supplied by SC here "https://www.sierrachart.com/index.php?page=doc/doc_VCExpress.php". I copied in the code from

SCSFExport scsf_WriteBarDataToFile(SCStudyInterfaceRef sc)

in the studies6.cpp, added the appropriate includes like:

#define WIN32_LEAN_AND_MEAN    // Exclude rarely-used stuff from Windows headers
// Windows header file
#include <windows.h>

but get the following compile error:

"error C2664: 'CreateFileW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR'"

for the line:

FileHandle = CreateFile(OutputPathAndFileName.GetChars(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL, NULL);

Thanks Bill
imageSierra_Chart_Error.png / V - Attached On 2016-05-22 17:58:53 UTC - Size: 85.52 KB - 253 views
[2016-05-23 20:23:58]
Sierra Chart Engineering - Posts: 104368
This:

"error C2664: 'CreateFileW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR'

Is the result of using a preprocessor definition or a compiler setting which is causing wide strings to be used rather than single byte strings.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2016-05-23 20:37:16]
User892558 - Posts: 5
Hi - just using default preprocessor settings and wouldn't know which compiler setting to cause wide strings. Just created a new project and voila. Here's the command line options: "/I"C:\SierraChart_Forex\ACS_Source\" /Zi /nologo /W3 /WX- /O2 /Oi /Oy- /GL /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "GSDCUSTOMSTUDIES_EXPORTS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Fp"Release\GSD Custom Studies.pch" /Fa"Release\" /Fo"Release\" /Fd"Release\vc100.pdb" /Gd /analyze- /errorReport:queue "
[2016-05-23 20:47:09]
Sierra Chart Engineering - Posts: 104368
This needs to be removed: /D "_UNICODE" /D "UNICODE"
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2016-05-23 20:52:48]
User892558 - Posts: 5
Yes, that was the problem. Have no idea how that option was changed from the default. Gremlins :)

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account