|
hi sidharth,
when u r passing string in vc++ they are accepted in BSTR format. so u have to first change into CString and then to char* to use it as a string.
function used to perform this is
#include<cstring.h>
CString CString_str = _T("");
if (BSTR_str != NULL) // To be sure that input string is valid...
{
CString s;
LPSTR p = s.GetBuffer(::SysStringLen(BSTR_str) + 1);
BOOL UsedDefaultChar;
::WideCharToMultiByte(CP_ACP, 0, BSTR_str, -1,
p, ::SysStringLen(BSTR_str)+1,
NULL, &UsedDefaultChar);
if (UsedDefaultChar)
// BSTR_str contains an ANSI string
CString_str = (LPCTSTR)BSTR_str;
else
// BSTR_str contains an UNICODE string
CString_str = (LPCWSTR)BSTR_str;
}
char *temp = LPSTR(CString_str);
further if u have to include MFC support at the time of creating new ATL project
I hope it will help u.
Ritu
|
|
|
|
|
Thanx a lot buddy. That was a breather. I will try and get back.But I am not using MFC. and if I include <iostream> it will create conflict. Any way let me try first.
|
|
|
|
|
Can i serialize an object with WTL like doing with MFC
vi
|
|
|
|
|
|
"the value of ESP was not properly saved across a function call." i got this error dialog while compiling a MFC client. the MFC client is empty except for a ATL control added to the UI. the ATL control is empty too. Just as it was 1st created by the wizard.
any idea what's wrong?
|
|
|
|
|
|
apparently the problem is with the compiling computer. it works fine in other computers. i tried installing MS SDK, VC++ SP5, clearing up the registry... and nothing works.. haha.. will be installing a new copy of VC++ today.. thanks for all the help guys. BUnch of great ppl we have here!!!
|
|
|
|
|
Hello everyone.
I am a beginner of WTL and STL.
Could you tell me whether STL can be used in a WTL project?
and I need to read data from file line by line,
is there a way to do it like "CStdioFile" of MFC?
Thank you.
-Freehawk
|
|
|
|
|
Hello,
Usel low level or stdio.h in WTL/ATL for e.g
fopen(....);
fwrite(...);
fread(...);
regards
balkrishna talele
|
|
|
|
|
Thank you for the fast reply.
is there way to read file line by line?
-Freehawk
|
|
|
|
|
Hey come on...
if you use
char *readme;
while(!feof(fp))
{
fscanf(fp,"%s",readme);
}
u will get line by line..
cheers
Balkrishna Talele
|
|
|
|
|
Thank you very much.
I will try it.
-Freehawk.
|
|
|
|
|
No you will not. You will get "token by token". Try fgets instead.
--
So let's just walk from place to place, as long as we don't talk face to face.
|
|
|
|
|
|
There you go, always thinking differetly
I have lost more blood shaving than on the battlefield - Adolf Hitler
|
|
|
|
|
freehawk wrote:
Could you tell me whether STL can be used in a WTL project?
STL can be used with any C++ project.
freehawk wrote:
and I need to read data from file line by line,
#include < iostream >
#include < fstream >
#include < string >
int main()
{
std::ifstream f( "c:\\test.txt" );
std::string fline;
while(std::getline( f, fline) )
std::cout << fline << std::endl;
return 0;
}
---
“Our solar system is Jupiter and a bunch of junk” - Charley Lineweaver 2002
|
|
|
|
|
Thank you and everyone very much.
It is useful to me and I can know it clearly.
-Freehawk
|
|
|
|
|
Less typing:
#include < iostream >
#include < fstream >
#include < string >
using namespace std;
int main()
{
ifstream f( "c:\\test.txt" );
|
|
|
|
|
I have a com object in which there are different properties. When i get these values through it works well when property is returning long or some other integer but it crashes when property is returning bstr. Take a look at my code and guide me that what i did wrong.
VARIANT pvResult;
memset(&pvResult, 0, sizeof pvResult);
VariantInit(&pvResult);
DISPID dispID=this->pColl->getMemberID(index);
DISPPARAMS dispParamsNoArgs={NULL,NULL,0,0};
HRESULT hr=pDispatch->Invoke(dispID,IID_NULL,LOCALE_USER_DEFAULT,
DISPATCH_PROPERTYGET,&dispParamsNoArgs,
&pvResult,NULL,&nArgErr);
Thanx in advance
Inam
|
|
|
|
|
The EOF marker has arisen from its MS-DOS grave to cause troubles for me -- I have an ifstream (which I open with the ios::binary flag specified) that refuses to read past a 0x1A byte. What am I doing wrong? The only calls I make are:
ticks.open(fn, ios::in || ios::binary);
...
ticks.seekg(fpos<int>(0, iter->offs));
...
ticks.read((char *) &data, sizeof (data));
if (ticks.eof()) return;
Whenever the initial byte of the block to be read is 0x1A, the read fails and eof() returns true. The same code works elsewhere and it's causing me a bit of grief. Any help greatly appreciated.
READIN writin rhythmetic
|
|
|
|
|
ticks.open(fn, ios::in || ios::binary); should be
ticks.open(fn, ios::in | ios::binary); but I don't happen to know how this could result in the strange behavior you describe.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Bingo! thanks, that's it -- the "ios::in || ios::binary" will of course resolve to 1, instead of the bitmap that I want. Thanks again; sometimes I need someone else to look at my code and point out the obvious mistake.
READIN writin rhythmetic
|
|
|
|
|
Hello everybody,
Does anybody know, how I can convert an in-proc server project written in ATL 3.0 (VC++ 6.0) to local server (exe version) or vice versa?
I mean that what changes, I have to make to the project settings and maybe to the source code and/or other files in the project? I have seen a sample project "ADOSAMP" that has several project settings for building dll or exe versions.
Regards,
Roozbeh
|
|
|
|
|
It's probably easier to just create a new project and copy the code from the in-proc project to the other. Make sure you update the .rgs files to reflect the new server type.
--
So let's just walk from place to place, as long as we don't talk face to face.
|
|
|
|
|
There is another way - DllSurrogate - which allows to use the in-proc as out-proc server.
With best wishes,
Vita
|
|
|
|