According to: http://msdn2.microsoft.com/en-us/library/td1esda9.aspx[^] the sizeof(array) should correspond to the number of 'characters' - not 'bytes'. So - in case of ANSI, it's bytes. In case of unicode, it's words (2-bytes). When the code you listed compiles for unicode, sizeof(array) is 200 - which is double the actual number of characters. Note that _tcscpy_s() zeros out the buffer after copying... and that's when you get the buffer overrun. You can find that out by stepping into _tcscppy(). You can use (sizeof(array)/sizeof(array[0])) or the _countof() macro. gmileka
georgeraafat
Posts
-
wcscpy_s issues [modified] -
Build ScriptYou can wrap this in a script and set it to be run as a post-build event. To do that, check out Project->Properties->configuration Properties->Build Events->Pre-Post-Build Event gmileka
-
CWinFormsControl ProblemWouldn't that change the class layout depending on who's including it? For example, if I include the header in a .cpp that is compiled native, the class layout does not contain the managed memeber. If I include the header in a .cpp that is compiled /clr, the class layout contains the managed memeber... This means they are essentially two different classes with the same name... The linker should emit an error in that scenario and not allow it... I haven't tried it though, so I might be wrong. gmileka
-
want to learn CLI, where to start?Depending on your goal of learning C++/CLI. You can think of C++/CLI as a language/technology just like C# - which means you don't have to learn COM to be able to write meaningful applications. However, in many cases, the reason people learn C++/CLI is to cross between the native and managed worlds... So, this means that the user need to understand their native code base and what technologies it is relying on to make the decision on what to learn... So, I think you won't 'have to' to learn COM unless you have some native C++ code that relies on COM... And for most native applications this is the case... The "Pro Visual C++/CLI and the .NET 2.0 Platform" book by Fraser and published by Apress is a good start... gmileka
-
COMCTRL32 ManifestThe wizard generated code for MFC apps adds code to stdafx.h to tell the linker to add the 6.0 manifest specific information. You can make sure you don't have this code for the dlls where you want to load the pre-6.0 dll. I would think that you need to load the pre-6.0 before loading the 6.0 one. gmileka
-
Visual Studio 2005 conversion problem/question.How about this: _AFX_THREAD_STATE* pState = AfxGetThreadState(); MSG msg = pState->m_msgCur; ? gmileka
-
Serialization Issue with Int32I think you need to change the defintion of TestStruct i from Int32^ i; to Int32 i; for this to work. gmileka
-
Mixing native and managed codeWhat is the runtime exception? Who is throwing it? You should not need to rebuild all your static libraries with /clr. You only need the /clr switch for the interop files - those the bridge the native and the managed world. gmileka
-
New Document in MDI applicationHow do you choose which window to write to? or which document/view to write to? Looks to me that you create the new document/view successfully, but you are still targetting the older (current) document/view... If that's the case, look for how to enumerate documents in the MDI app and then you can direct your output to the write document... gmileka
-
How can I Export DllUnregisterServer in VC++?I'm curious how the MFC dll was created through the Wizard... and which VS is being used. Since this is a C++/CLI forum, I would expect some interaction between the 'managed' MFC stuff and your declaration. gmileka
-
How can I Export DllUnregisterServer in VC++?Based on: http://msdn2.microsoft.com/en-US/library/5k6kw95a.aspx[^] You will get this error if the prototype is defined twice with different linkage... In otherword, some already defines DllRegissterServer(void) before you header definition... To find it, you could add the compiler switch /P to the CPP including the header file. Then, right-click on the file and select 'compile'. This will output a file to disk that has all the included file and the line numbers... You can then search it for DllRegisterServer and figure out where it's coming from. Remember to remove the /P switch before building your project. I'm not sure what type of MFC dll you're using - but the other definition is coming from MFC most likely... gmileka
-
How can I Export DllUnregisterServer in VC++?STDAPI resolves to EXTERN_C HRESULT STDAPICALLTYPE So, both STDAPI __declspec(dllexport) and __declspec(dllexport) ATDAPI won't work because of the order of individual pieces when mixed with __declspec. The following seems to work and achieves the same result: Header: extern "C" __declspec(dllexport) HRESULT __stdcall MyFunc(void); CPP: HRESULT __stdcall MyFunc(void); { } If I do a "dumpbin /exports dllname.dll", I get _MyFunc. gmileka
-
[MFC] TextBoxYes - ES_NUMBER is defined in winuser.h. The .rc files can include headers. gmileka
-
[MFC] TextBoxYou can use the ES_NUMBER style when creating the control. If the IDE does not expose this style, edit the .rc manually and add it. gmileka
-
How can I Export DllUnregisterServer in VC++?What is the error you get? gmileka
-
Newbie: About passing parameter into a formYou need to convert the 'int i' to a C string. You could use itoa() or printf(). Make sure the buffer is large enough to hold the resulting string. Once you have a C string, convert it to a 'System::String'. You don't need to convert it to __gc textbox because you're assigning it to the 'Text' property of the text box... The property expects a string. gmileka
-
Microsoft is looking for potential C++ MVPsThey have MVPs all over the world. They are not only looking for North America MVPs. gmileka
-
Newbie: Using a com object in VC 7.1The following line: InDesign.Application app = (InDesign.Application) COMCreateObject("InDesign.Application"); should be: InDesign::Application app = (InDesign::Application) COMCreateObject("InDesign.Application"); (not sure what COMCreateObject returns). In general, whenever you are qualifying something with a namespace, use the scope operator ::. Unlike C#, C++ differentiates between types and instance of types. For type qualification, it's type::identifier or namespace::identifier For instance qualification, it's instance.identifier or instance->identifier (those are only examples of course). C# always uses the dot operator no matter what... gmileka
-
Newbie: Using a com object in VC 7.1The 'using' statement should do the trick. Why do you have it commented out? gmileka
-
Constructor problemI would add a constructor to tDot. class tDot { public: float fX, fY; tDot(float newfX, float newfY){ fX=newfX; fY=newFY; }; }; class tCircle { public: tCircle( void ); tCircle( float, float, float ); tCircle( tDot, float ); public: float fRadix; tDot cCenter; }; tCircle::tCircle(double newX, double newY) : cCenter( newX, newY) { } gmileka