|
I read this article, but i didn't understand !!!
Can you write an example ???
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hmm. Here it is :
USES_CONVERSION;
OLECHAR* pOLECHAR = A2OLE("example");
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
I got 3 errors:
error C2440: 'initializing' : cannot convert from 'int' to 'unsigned short *'
error C2065: 'A2OLE' : undeclared identifier
'USES_CONVERSION' : undeclared identifier
Are you sure i don't need with any header file ???
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
try #inlclude <atlconv.h>... but I'm not sure is it posssible to include this file directly ... Is your project ATL-based ?
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
My program is MFC mode.
I think wchar_t is equal with OLECHAR ...
Does i have not any other way ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
include [atlconv.h] file into your source file and try A2OLE macro.
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
Excellent ...
Thanks aloooooooot for your answers and your time.
Now, my program will work, perfectly ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Please be aware that you should NOT use OLE2A in a tight loop.
This is will propably crash:
void main()
{
USES_CONVERSION;
LPSTR sz="";
BSTR bstr = L"Goodbye, World...";
for (int i=0 ; i<100000 ; i++)
sz = OLE2A(bstr);
}
The reason is that OLE2A allocates memory on the stack for performance reasons, so you will run out of stack space if you do not take care to leave scope once in a while.
Instead, put your OLE2A macro in a separate function, where it is certain that it will not be called several times without leaving scope - or use dynamically allocated mamory (slower but safer).
Christian Skovdal Andersen
|
|
|
|
|
Just one quick comment on the ATL convertion macro's.
They alloc the string on the stack, using _alloca(), so they are no good for long strings, or when used in a loop...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Yeah, right. But there is a ocscpy() function to copy converted string into a pre-allocated memory.
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
|
|
Where do you find that function?
It's not documented anywhere in the MSDN Libaray...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Try to "Search" Tab in MSDNL. =)
ps: I've faced this function when I've been programming SnapIn.
ps2:here is the local address in my hard disk: (but I'm not sure that URL will be correctly displayed in forum):
mk:@MSITStore:C:\Program%20Files\Microsoft%20Visual%20Studio\MSDN\2000OCT\1033\period99.chm::/html/VC99A01.htm
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
Found it
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi Andres,
You A2OLE isn't good for use in long strings ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
If you use a standard stacksize and convert more than 1 mb with the ATL macro's, you get a stack overflow error, and your app. crashes...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
So, if my data was more 1 MB then i must use _alloca() ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
No, it means you should change stack size. (in linker's options)...
ps: it's a never-ending thread =)
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor_soukhov@yahoo.com | ICQ:57404554 | http://siv.da.ru
|
|
|
|
|
I don't think changing stack size is such a good idea.
If you change data you don't know the size of, at compiletime, you never know if your program works...
ps: it's a never-ending thread =)
Yep
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Nope, the ATL conversion macro's uses _alloca(), which allocates on the stack.
If you want to convert, say 5 mb, you cannot use theese macro's, but have to do it in another way, where you can allocate your memory on the heap...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
A2OLE allocate memory from stack ?
Or do you mean SysAllocString for BSTR strign ???
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
A2OLE allocate memory from stack?
Yes
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Good, so how can i allocate memory from heap for A2OLE ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi all.
What is Requery() ???
Is it for refresh recordset ?
So, when i add/new/delete/edit each record, i must use it ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|