|
CString str=_T("Hello");
const char *buffer;
buffer=(const char*)LocalAlloc(LPTR,20);
strcpy((char*)buffer,str);
LocalFree((HLOCAL)buffer);
|
|
|
|
|
Monty2 wrote: Try this
const char * pVal = (LPCTSTR)sVal;
Can I add something?
Using this way we have to be carefull using pVal in WRITE mode: the pointer points to the local CString object!
Hope it helps.
|
|
|
|
|
_Russell_ wrote: Using this way we have to be carefull using pVal in WRITE mode: the pointer points to the local CString object!
Ofcourse
Thanks for the correction.
Large cats have been scientifically proven to dream. Among the recurring themes are balls of yarn, mice, and half-blind overweight shackled oryx.
|
|
|
|
|
const char * pVal = sVal.c_str();
|
|
|
|
|
The other answers won't work in a Unicode build. You need to convert your CString to ANSI to assign it to a char* variable. The quickest way is:
#include <atlconv.h>
{
USES_CONVERSION;
CString sVal = _T("something");
const char* p = T2CA(LPCTSTR(sVal));
}
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Hello,
How can I check on which paltform the program is running?
(Such as: windows 2003, NT, 98 etc).
Thanks.
-- modified at 9:34 Monday 8th May, 2006
|
|
|
|
|
Try GetVersionEx[^]
Large cats have been scientifically proven to dream. Among the recurring themes are balls of yarn, mice, and half-blind overweight shackled oryx.
|
|
|
|
|
What are the advantages of unmanaged code over managed code and vice versa?
|
|
|
|
|
acemahesh@yahoo.co.in wrote: the advantages of unmanaged code over managed code and vice versa
Freedom, flexibility, ...
Maxwell Chen
|
|
|
|
|
I have created an applicatio having six child dialog. WHen you press ALT+Tab when window is in focus another window which was in focus gets displayed and again if I try doing the same thing the orginal window is displayed .....
But one of my child dialog some thread are executing and IF i press ALT+tab to display it again the windows does not appears but the process continues. When the threads process is completed the window functions well...
I tried with VK_TAB and VK_ALT but it does not work
Cheers
"Peace of mind through Technology"
|
|
|
|
|
Ganesh_T wrote: But one of my child dialog some thread are executing
Are you sure that there is another thread rather than the main thread is doing the process?
- NS -
|
|
|
|
|
yes I am starting five threads.....by AfxBeginThread
Cheers
"Peace of mind through Technology"
|
|
|
|
|
Ganesh_T wrote: yes I am starting five threads
And you talk of six child windows...
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
I am starting these all threads from one of my child dialog.
I am not starting threads for creating the child dialogs
Cheers
"Peace of mind through Technology"
|
|
|
|
|
Ganesh_T wrote: But one of my child dialog some thread are executing and IF i press ALT+tab to display it again the windows does not appears but the process continues. When the threads process is completed the window functions well...
That's because the thread isn't processing window messages, so the dialog can't repaint.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Hi Every one,
I'm programming in VC++ and I created a dll(MFC dll) with VC++,in this dll I'd like to have a function that export to out,I can do it ,but when I declare DllRegisterServer function I can't export it.
My code is same as folowing code:
__declspec(dllexport) STDAPI DllRegisterServer(void);
how can I export DllRegisterServer or DllUnregisterServer function that implemented in a dll ?
Please help me.
Best Regards.
Orchid
|
|
|
|
|
What are you trying to do exactly ? Why do you want to export this function ? I don't know exactly its prupose but isn't it related to COM (not sure at all) ?
|
|
|
|
|
Cedric Moonen wrote: isn't it related to COM
Yeah it is. It is used to unregister a COM component.
Nibu thomas
Software Developer
Faqs by Michael dunn
|
|
|
|
|
I'd like to create a cryptographic service provider ,for example in rsaenh.dll there are many functions and this dll can export DllUnregisterServer and DllregisterServer ,I need do same as rsaenh.dll but I can't export this function from my dll?I hope it was clearly.
If you have any idea please inform me.
Best Regards.
Orchid
|
|
|
|
|
It is because these dll are COM components (I suppose). Why do you want to do the same ?You can simply have a dll and exports the functions you need, why do you want to register it as a COM component ?
|
|
|
|
|
I need provide a cryptographic service provider (CSP) and every CSP needs to have a dll ,I need create a dll same as rsaenh.dll but not exactly same of rsaenh.dll I should change a bit it and replace my dll with rsaenh.dll .
I don't understand "COM components" that you mentioned.If it isn't possible do that,how rsaenh.dll can do it,please explain me complete and step by step about "COM component" that you mentioned.
Best Regards.
Orchid
|
|
|
|
|
I think you first need to define more in details want you want to do (for yourself I mean). Simply saying that you want to do the same as '....' without understanding the concepts behind that will lead you to nowhere (for example here, you want to use some COM functionalities without knowing what a COM component is).
Can't you do that simply with a dll ? Why do you need to register it as a COM component (and tell me it's because rsarnh.dll does that also, I want a good reason why you want to do that).
Sorry, but if all you want to do is a kind of 'copying' an existing thing, I cannot help you (because you need first to understand the concepts before using that).
|
|
|
|
|
I 'm sorry ,I think I couldn't explain you my idea well,
In my project I need create a CSP for our goal ,for example I need change the digital signature in word and for this goal I should create a CSP and install it in windows.I need a CSP same as "Microsoft Strong Crypto Provider" that "Microsoft Strong Crypto Provider" uses rsaenh.dll ,I should have a dll same as rsaenh.dll that "Microsoft Strong Crypto Provider" used it, but my dll isn't exactly same as rsaenh.dll ,it have a bit differ of it. I tried to make a dll with VC++ same as rsaenh.dll because my dll should replace with rsaenh.dll and my dll should have all of functions that rsaenh.dll have used ,one of this function is DllregisterServer and DllUnregisterServer .but when I implement them and export them ,I saw my dll can export all of functions except DllUnregisterServer and DllregisterServer .
I hope I could explain my goal now.
Please help me.
Best Regards.
Orchid
|
|
|
|
|
Open the dll using Depends.exe and see what functions are being exported, i suspect that c++ is decorating the name if that is the case declare the function as "C" (extern "C" void f(int); ).
Large cats have been scientifically proven to dream. Among the recurring themes are balls of yarn, mice, and half-blind overweight shackled oryx.
|
|
|
|
|
I open rsaenh.dll with "DLL Export Viewer" I think this is same as Depends.exe that you mentioned but I see the DllUnregisterServer and DllregisterServer functions are exported and my dll can export these functions ,I can't understand meaning the sentence that you mentioned:
"C++ is decorating the name if that is the case declare the function as "C" (extern "C" void f(int); ). "
Please explain it if it is possible for you.
Best Regards.
Orchid
|
|
|
|