|
dear all,
how can i pass CString objects in API functions which expect:-
LPCTSTR
LPCWSTR
LPCTSTR
LPTSTR -> is there any other way than CString::GetBuffer
LPWSTR
PCSTR
thanx
|
|
|
|
|
Where you want a wide string, use _bstr_t, the constructor builds an object which contains both a wide and narrow string, with operators for both. That may well work for all the things you list. I think it's defined in comdef.h, or somesuch.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
thanx Christian,
but can u illustrate some example for such conversions
|
|
|
|
|
basically, if a function needs one of those things, and you have a CSTring called s, do this
myfunc(_bstr_t(s));
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
thanx Christian for the help!
but is the method safe and effective?
|
|
|
|
|
rishabhs wrote:
but is the method safe and effective?
Gosh you're a worry wart !!!
Yes, it's fine. The constructor builds a class, that class passes the required result to the function and on return the class destructor cleans up after itself. Windows is full of string conversion routines, but I find the _bstr_t method nice and easy.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Aint you wasting your time a little bit, trying to explain details when you know Dunn did a couple tutorials about it ? When you know how recurrent these posts about strings are, that's a complete shame each person posting in the VC++ forum is not offered a poll before they really get to the posting form, and that would go like this :
- question 1 : is your question about strings (translate that one to indian too) ?
If answer is yes, throw the Dunn tutorials to his head.
Otherwise,
- question 2 : are you sure your question is not related to characters or the CString class ? (please note the irony )
- question 3 : in case your question has to do with a LPSTR topic or something like that, then please consider looking those articles : 1[^] and 2[^].
|
|
|
|
|
thanx .S.Rod. for the hammering!
i had no knowledge about the tutorials, that's why i thought i could get some helping hand in the forum.
anyways thanx for the links u've shown me! i think they'll help my cause.
i think u were sarcastic in the reply!
i could'nt understand some of the remarks!
thanx
|
|
|
|
|
rishabhs wrote:
thanx .S.Rod. for the hammering!
This is a reply to the grausian answer to your post. I have made a reply for you just below.
|
|
|
|
|
sorry rod!
those articles were really helpful,
but still i think u were rude!
|
|
|
|
|
Good point, I must admit I forget about those as well.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
|
I want to get every HTML page when IE load it, any idea?
Thank you.
|
|
|
|
|
Either you can Embedd Web Browser component and load respective html page or
use following in a DialogBox for invoking Html page:
HWND h = FindWindowEx(NULL,NULL,NULL,"Microsoft Internet Explorer");
ShellExecute(h,"open","http:\\\\www.funducode.com",NULL,NULL,SW_SHOWNORMAL);
|
|
|
|
|
Hello Dear All,
I've been doing Windows NT 4.0 development since 1997 and I'm relatively new to Windows XP. I've recently heard that Named Pipes are no longer supported in Windows XP or that it will be gradually phased out in the long run.
I'm wondering if this is truly the case. I've referred to the MSDN documentation for Named Pipes and noted that it is supported in XP and there is no mention of it becoming obsolete.
I personally do not think Named Pipes will become obsolete anytime in the future but has anyone vaguely heard of this possibility ?
Thanks, All,
Bio.
|
|
|
|
|
Hi guys,
I've a dial up connection available on a pc to which I'm connected via LAN. I want to connect to internet using this dial up connection. How can I do that? Is it possible to invoke that dial up connection through my program also.
Thanks
Deepak
|
|
|
|
|
im looking for the fastest, easiest, (hopefully very W3C conformant) XML parsing/writing library -- preferably support for event-based parsing
i've tried microsoft's MSXML but it's unbelievably hard to use with all the COM interfaces and stuff it gets annoying
thanks for the help
- Roman -
|
|
|
|
|
one of the fastest is expat[^] (James Clark, W3C). And yes it's event based. It doesn't write Xml though.
(MSXML 4.0 is f***ing fast either, but the SDK has limitations, and it's of course full of proprietary interfaces and behaviours).
|
|
|
|
|
Does anyone know of universal naming convention (UNC) path?
thank you
|
|
|
|
|
UNC paths AFAIK, start with "\\", such as "\\server\share\". Take a look in the MSDN for further information.
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
Is there any sample code using an ActiveX control (ie. MSFlexGrid) in a DLL Dialog that is loaded dynamically by the client.
|
|
|
|
|
I initially started this message thread as I had a problem getting the ado connection at startup....
i had written the exe path in a key in registry
"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\\Run"...though the exe startsup an ado connection error is thrown if ado connection is tried in InitInstance of the app
ive finally got it right..consider the following code
-----------------------------------
CoInitializeEx(NULL, 0x02);
try{
_ConnectionPtr mpDBConnection;
mpDBConnection.CreateInstance(__uuidof(Connection));
HRESULT hRes=mpDBConnection->Open(_T("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database\\TrialDB.mdb;Persist Security Info=False"),"","",adConnectUnspecified);
CStartUpDlg dlg;
m_pMainWnd = &dlg;
...
...
..
-----------------------------------
this works fine when normally executed and the database connection is ok.
however in startup when saying "database\TrialDB.mdb" instead of refering to the relative path of the application it assumes it as being in "c:\" drive.....
and therefore looks for the database in "c:\database\TrialDB.mdb" ..
and obviously as there is no database there the connection fails.
however if the code is changed tohaving the follwoing lines occure before the connection is opened like below
-----------------------------------
CoInitializeEx(NULL, 0x02);
try{
CStartUpDlg dlg;
m_pMainWnd = &dlg;
_ConnectionPtr mpDBConnection;
mpDBConnection.CreateInstance(__uuidof(Connection));
HRESULT hRes=mpDBConnection->Open(_T("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database\\TrialDB.mdb;Persist Security Info=False"),"","",adConnectUnspecified);
...
...
..
-----------------------------------
the conection works fine in startup as well..
but unfortunately as i need to do the database connection before I create the dialog object..... the question persists...
1.Why cant i get the relative path in startup????
2.Please suggest an alternative solution to get the relative path....
i mean besides using get CurrentDirectory() and that kind of stuff
Consider for example when we create a shortcut
we can specify a 'start in' directory
and all relative paths refer to this strt in directory right??
is there anywhere i can specify such a 'start in' directory for an application in registry!!!
if there is any other method to get the relative path of the app please tell me...
|
|
|
|
|
If you want to get the path of the .exe at runtime, take a look here:
http://www.codeproject.com/cpp/cppforumfaq.asp#win_exepath[^]
You can strip off the exe name, and then you have the directory the program is running from.
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
thankx but no thankx
cause one i already said i didnt need more apis like GetCurrentDirectory()
hells there s countless methods where i can get the app path and then go on for concatenating
and secondly and more importantly my primary question as to why the relative path isnt recoognised at startup remains unanswered.
i was thinking more in lines of as how the application framework finds its the current directory.....
if there must be some variable on m_pMainWnd or soemthing setting that would men lesser work and a more efficient solution than changing of code for the concatenation...
for example app has m_pszHelpFilePath to set the help file path
there must be something where the path is stored so that the exe can refer to it when a relative path is called
if im wrong pls correct me?
and pls tell me whythe relative path isnt recoognised at startup remains unanswered.
|
|
|
|
|
Well, no matter which route you go, you will almost undoubtably end up using GetModuleFileName (directly or indirectly). CWinApp is even using it to format the m_pszHelpFilePath (take a look in MFC sources).
Why isn't the relative path recognized at startup? Well, it is being recognized. It's just that it's being recognized as being relative to the "C:\" path, instead of the path your app resides in. Putting relative paths in your program and depending on Windows to set your directory for you is never a good idea, and the best way to not do it, is probably to use GetModuleFileName. It will be all of 6 lines of code, and you will remove the risk of not finding your database (unless the database gets deleted).
fordge wrote:
there must be something where the path is stored so that the exe can refer to it when a relative path is called
Refer to the documentation on CreateFile or the Open method of the database connection object for a list of paths that are searched when you use a relative path name.
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|