I was trying to compile one of my C++ projects and ran into this error:
Error 1 error C2872: 'IServiceProvider' : ambiguous symbol C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\ocidl.h 8005
Among other files in the project, I had a header file which started like this:
using namespace System;
#include "MyHeader1.h"
#include "MyHeader2.h"
After a little research I have found the cause of this error. I turned on the /showIncludes option of the compiler and saw that one of my headers was actually including the "ocidl.h" file. The Build output will show, among others:
...
2>Note: including file: C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\atlcomcli.h
2>Note: including file: C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\olectl.h
2>Note: including file: C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\pshpack8.h
2>Note: including file: C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\ocidl.h
...
In order to fix this compile time error, I moved the using below the #include as below and it all started working again:
#include "MyHeader1.h"
#include "MyHeader2.h"
using namespace System;
miercuri, 16 martie 2011
Error C2872 ambiguous symbol
joi, 17 februarie 2011
Passing an array to a function in C++
In C++ you if you want to modify an array inside a function, you should not return a pointer to it from within the function as this pointer will be out of scope when the function execution ends. You need to make sure that you allocate the array before passing it as a parameter:
int* buffer = new int[ BUFFER_SIZE];
arrayProcessing( buffer, BUFFER_SIZE );
#ifdef _DEBUG
DisplayBuffer( );
#endif
where arrayProcessing is defined like this:
int arrayProcessing( int* buffer, int size )
{
// TODO: modify elements of buffer.
}
int* buffer = new int[ BUFFER_SIZE];
arrayProcessing( buffer, BUFFER_SIZE );
#ifdef _DEBUG
DisplayBuffer( );
#endif
where arrayProcessing is defined like this:
int arrayProcessing( int* buffer, int size )
{
// TODO: modify elements of buffer.
}
miercuri, 12 ianuarie 2011
How to open a .pdf or .txt file in C#
This is a simple question, with a very simple answer. I've been asking it myself and seeing other people ask it. A solution is to use the System.Diagnostics.Process.Start( ) method.
According to MSDN, using this method is very similar to typing the file's name in the Run dialog box of the Windows start menu.
For instance, if you have a .pdf file that you want to open, just use:
System.Diagnostics.Process.Start( "myfile.pdf" );
You can follow this link for more information: http://msdn.microsoft.com/en-us/library/53ezey2s.aspx.
For a text file, you can use the above method, or if you want to specifically open it with notepad you have to use:
System.Diagnostics.Process.Start( "notepad.exe", "myfile.txt" );
According to MSDN, using this method is very similar to typing the file's name in the Run dialog box of the Windows start menu.
For instance, if you have a .pdf file that you want to open, just use:
System.Diagnostics.Process.Start( "myfile.pdf" );
You can follow this link for more information: http://msdn.microsoft.com/en-us/library/53ezey2s.aspx.
For a text file, you can use the above method, or if you want to specifically open it with notepad you have to use:
System.Diagnostics.Process.Start( "notepad.exe", "myfile.txt" );
marți, 6 iulie 2010
Changing the location of My Documents in Windows CE
In this post I'll show you how to change the default location of the My Documents folder from the internal RAM to a flash disk location or SD card for your Windows CE device. This is mainly the case because Active Sync uses this folder to synchronize files with the device and initially, My Documents is located into a volatile memory region and all data saved there will be lost after a device reboot. Even worst is the fact that after the reboot, the synchronization process will erase all your files from the desktop PC as well.
So, in order to change the location of My Documents to the flash disk, open the Windows CE registry editor and open the key:
[HKEY_LOCAL_MACHINE\System\StorageManager\MSFLash]
and change the values of Folder and Name to "My Documents" ( without the quotes ).
Then choose to save your registry and reboot your device.
After the reboot, the Flash disk will appear renamed to "My Documents" and you can set-up a synchronized connection with the PC using Active Sync without having to loose the files every time you reboot.
So, in order to change the location of My Documents to the flash disk, open the Windows CE registry editor and open the key:
[HKEY_LOCAL_MACHINE\System\StorageManager\MSFLash]
and change the values of Folder and Name to "My Documents" ( without the quotes ).
Then choose to save your registry and reboot your device.
After the reboot, the Flash disk will appear renamed to "My Documents" and you can set-up a synchronized connection with the PC using Active Sync without having to loose the files every time you reboot.
Abonați-vă la:
Postări (Atom)