Discussion:
HELP with error C1189: Need to include strsafe.h after tchar.h
(too old to reply)
emetress
2006-05-11 21:57:18 UTC
Permalink
HI I get this error:

C1189: #error : Need to include strsafe.h after tchar.h

I included all the directories that I think I need and this is my
code,as you can see I have all the necessary includes..

#include <streams.h>
#include <Qedit.h>
#include <atlbase.h>
#include <dshow.h>
#include <stdio.h>
#include <initguid.h>
#include <tchar.h>
#include <strsafe.h>
#include "cabecera.h"

void main(){

CComPtr< ISampleGrabber > pGrabber;
CComPtr< IBaseFilter > pSource;
CComPtr< IGraphBuilder > pGraph;
CComPtr< IVideoWindow > pVideoWindow;
HRESULT hr;

// Create the sample grabber

pGrabber.CoCreateInstance( CLSID_SampleGrabber );

CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabberBase( pGrabber );


hr = GetVideoInputFilter(&pSource);

// Create the graph

pGraph.CoCreateInstance( CLSID_FilterGraph );

// Put them in the graph

hr = pGraph->AddFilter( pSource, L"Source" );
hr = pGraph->AddFilter( pGrabberBase, L"Grabber" );

// Tell the grabber to grab 24-bit video. Must do this
// before connecting it

CMediaType GrabType;
GrabType.SetType( &MEDIATYPE_Video );
GrabType.SetSubtype( &MEDIASUBTYPE_RGB24 );
hr = pGrabber->SetMediaType( &GrabType );

// Get the output pin and the input pin

CComPtr< IPin > pSourcePin;
CComPtr< IPin > pGrabPin;

GetPin(pSource, PINDIR_OUTPUT, 0, &pSourcePin);
GetPin(pSource, PINDIR_INPUT, 0, &pGrabPin);

// ... and connect them

hr = pGraph->Connect( pSourcePin, pGrabPin );

// Render the grabber output pin (to a video renderer)

CComPtr <IPin> pGrabOutPin;
GetPin(pGrabberBase, PINDIR_OUTPUT,0,&pGrabOutPin );
hr = pGraph->Render( pGrabOutPin );

}


What am i doing wrong?
Thank you
Peter Duniho
2006-05-12 03:22:08 UTC
Permalink
Post by emetress
C1189: #error : Need to include strsafe.h after tchar.h
I included all the directories that I think I need and this is my
code,as you can see I have all the necessary includes..
#include <streams.h>
#include <Qedit.h>
#include <atlbase.h>
#include <dshow.h>
#include <stdio.h>
#include <initguid.h>
#include <tchar.h>
#include <strsafe.h>
#include "cabecera.h"
[...]
What am i doing wrong?
I haven't looked at the other includes, but I will bet that one of the
includes before tchar.h is including strsafe.h. Thus when you get to
tchar.h, strsafe.h has already been included, and thus the error.

The fix would be to move tchar.h to above whatever include file is including
strsafe.h. I would guess that you could successfully include it as the very
first include file.

Pete

(am I alone in thinking that someone who cannot properly diagnose basic
compile and/or link errors is someone who will probably have a lot of
trouble figuring out DirectShow, and maybe shouldn't be trying in the first
place?)
The March Hare [MVP]
2006-05-12 14:44:17 UTC
Permalink
Post by Peter Duniho
(am I alone in thinking that someone who cannot properly diagnose basic
compile and/or link errors is someone who will probably have a lot of
trouble figuring out DirectShow, and maybe shouldn't be trying in the first
place?)
I made this point on one of the OP's first questions here.
--
Please read this before replying:
1. Dshow & posting help: http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others: follow up if you are helped or you found a solution
Loading...