Need help in string conversion

Hi,

This might be a stupid question, but being a novice I 
can't help without asking someone. How can I convert a 
string to LPTSTR? For example I have,

string command = "runMe -f test.txt";
command += anotherString;

LPTSTR commandLine = command; //this won't work and that 
is where I need your help.

Thanks in advance,

Rajesh
0
anonymous (74722)
10/23/2003 11:12:32 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
754 Views

Similar Articles

[PageSpeed] 35

    LPTSTR can become a LPWSTR or LPSTR based on whether you have UNICODE
defined.  You can relate 'string' to LPSTR  and 'wstring' to LPWSTR.  So you
have two options.

    1. Use a generic 'tstring' which becomes a string/wstring based on
UNICODE definition. Something like

            #include <tchar.h>

            typedef std::basic_string<TCHAR> tstring;

            tstring command( TEXT( "runMe -f test.txt" ) );
            command += anotherString;
            LPTSTR commandLine = command._cstr();

    2. use LPSTR instead of LPTSTR if you do not care about UNICODE.
Something like

        string command = "runMe -f test.txt";
        command += anotherString;

        LPSTR commandLine = command.c_str();

    HTH.

-- 
Cheers
Check Abdoul [VC++ MVP]
-----------------------------------

"Rajesh" <anonymous@discussions.microsoft.com> wrote in message
news:06a301c399bb$2366a750$a101280a@phx.gbl...
> Hi,
>
> This might be a stupid question, but being a novice I
> can't help without asking someone. How can I convert a
> string to LPTSTR? For example I have,
>
> string command = "runMe -f test.txt";
> command += anotherString;
>
> LPTSTR commandLine = command; //this won't work and that
> is where I need your help.
>
> Thanks in advance,
>
> Rajesh


0
CheckAbdoul
10/23/2003 11:30:35 PM
Hi,

Thanks for your prompt response. I tried your second 
suggestion, but it is giving me the following error

error C2440: 'initializing' : cannot convert from 'const 
char *' to 'LPSTR'

Could you please help me?

Thanks in advance,

Rajesh

>-----Original Message-----
>    LPTSTR can become a LPWSTR or LPSTR based on whether 
you have UNICODE
>defined.  You can relate 'string' to LPSTR  and 'wstring' 
to LPWSTR.  So you
>have two options.
>
>    1. Use a generic 'tstring' which becomes a 
string/wstring based on
>UNICODE definition. Something like
>
>            #include <tchar.h>
>
>            typedef std::basic_string<TCHAR> tstring;
>
>            tstring command( TEXT( "runMe -f 
test.txt" ) );
>            command += anotherString;
>            LPTSTR commandLine = command._cstr();
>
>    2. use LPSTR instead of LPTSTR if you do not care 
about UNICODE.
>Something like
>
>        string command = "runMe -f test.txt";
>        command += anotherString;
>
>        LPSTR commandLine = command.c_str();
>
>    HTH.
>
>-- 
>Cheers
>Check Abdoul [VC++ MVP]

0
anonymous (74722)
10/23/2003 11:55:18 PM
c_str returns an LPCTSTR (constant).  

Use const_cast to cast away the const attribute. 

     const_cast<LPSTR>(string.c_str());

or use const type for commandline 

     LPCTSTR commandLine = command.c_str();

David
>-----Original Message-----
>Hi,
>
>Thanks for your prompt response. I tried your second 
>suggestion, but it is giving me the following error
>
>error C2440: 'initializing' : cannot convert from 'const 
>char *' to 'LPSTR'
>
>Could you please help me?
>
>Thanks in advance,
>
>Rajesh
>
>>-----Original Message-----
>>    LPTSTR can become a LPWSTR or LPSTR based on 
whether 
>you have UNICODE
>>defined.  You can relate 'string' to LPSTR  
and 'wstring' 
>to LPWSTR.  So you
>>have two options.
>>
>>    1. Use a generic 'tstring' which becomes a 
>string/wstring based on
>>UNICODE definition. Something like
>>
>>            #include <tchar.h>
>>
>>            typedef std::basic_string<TCHAR> tstring;
>>
>>            tstring command( TEXT( "runMe -f 
>test.txt" ) );
>>            command += anotherString;
>>            LPTSTR commandLine = command._cstr();
>>
>>    2. use LPSTR instead of LPTSTR if you do not care 
>about UNICODE.
>>Something like
>>
>>        string command = "runMe -f test.txt";
>>        command += anotherString;
>>
>>        LPSTR commandLine = command.c_str();
>>
>>    HTH.
>>
>>-- 
>>Cheers
>>Check Abdoul [VC++ MVP]
>
>.
>
0
anonymous (74722)
10/24/2003 7:15:27 AM
Reply:

Similar Artilces:

string value
I am using a loop to iterate through a list and sometimes need one vbTab in the code, other times need (2): vbTab & vbTab : For each Tcolumn in rs.Fields strMy=strMy & vbTab & column.Name & vbCrLf Next Tcolumn How can I do this? If I use a variable, it is not recognized by Access as the vbTab code. Thanks! Sam strMy=strMy & vbTab & iif(Needs2, vbTab, "") & column.Name & vbCrLf Replaces Needs2 with an expression that is true when you need two tabs. HTH John ################################## Don't Print - Save trees smk23 wrote: > I ...

My category heirarchy got messed up
I just noticed today that my category database seems to be messed up. I'm using Money2003 Deluxe. I started to describe this using generic names, but it was too confusing. So, I'll try it with actual names: The problem: I used to have an Expense category called Personal Care with two subcategories, Fitness and Haircuts. Today, I noticed that these two categories seem to have disappeared from my Money file. They do not show up under Personal Care on the "Set up your Categories" screen. Transactions which formerly had these categories assigned are now mostly showin...

some one help me please
Can someone help me i need to get the total from the amount column to generate over to the amont paid column, the to columns always are the same amount. this is how my spreadsheet looks. Loan # Invoice # Invoice Date Amount Date Paid Amount Paid please help Hi In cell F2 enter =D2 Copy down as appropriate. Regards Roger Govier inneedjen wrote: > Can someone help me i need to get the total from the amount column to > generate over to the amont paid column, the to columns always are the same > amount. this is how my spreadsheet looks. > Loan # Invoice # Invoice Date Amou...

Need a little help setting fonts...
Hello, I need to change the fonts on my applications so that they can use the Registered and Trademark symbols. The Trademark symbol doesn't appear to be in the MS Sans Serif font. MS Word with that font does show it though. Anyway, I've noticed that W2K and XP now use a differnt font. I've forgotten the name of it at the moment. Anyway, I've discovered a minor problem with the way Windows and fonts work and could use some help determining the correct resolution. I've tried changing the fonts in all my windows to the new font. This works pretty much okay. Ho...

Need Help with log on
I have frontpage and have always edited my site using it, my computer crashed, we got a new one and installed frontpage again. In the past when I would go to edit my site a box would come up asking for my user name and password so I could connect to the host server (I think thas what it is called) Anyway now no box comes up at all and I do not seem to beable to edit anything. I have asked my web host and they can not help me. The site is up and working but I can not make changes. Sorry I do not understand much of the tech stuff. I had a lady who did this for me but she is no lon...

Help with reading attributes
Hi, I have this xml structure <listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <rs:data ItemCount="1"> <z:row ows_AZNamnUppdragsansvarig="Peter" ows_AZTypAvUtbetalning="Arvode till privatperson" ows_AZPersonnummer="196202081276" ows_AZPlusgiro="5456436534" ows_MetaInfo="1;#"...

teredo tunneling psuedo-interface code 10??? affecting my usb now i cant download music onto my ipod help!!
so i just got an ipod and when i pluged it in it said that and ipod was detected but could not be......( i forgot the rest) please unplug and try agian and it dosent work . so then i downloaded tune up utilities and it said i had 3 errors ,2 of wich really dont matter, but then i looked at the 3rd one and it said i had a code 10 on my teredo tunneling psuedo interface and it could not start. please help me!!!!! -- etfboy450 ------------------------------------------------------------------------ etfboy450's Profile: http://forums.techarena.in/members/169455.htm View this t...

Need IF Formula Help
Hi Guys Am attempting to write a formula with 2 ranges of outcome. Here's what I have so far and you can tell me what's wrong because I'm getting a #value! error message instead of an answer =IF(AND(G4)<=0.5,sum=0),IF((G4)>=1.5,(sum=0.5*(F5)) If a specific cell has a response that is less than .5, I need it to return a zero answer. If that same cell's response is greater than 1.5, I need it to multiply .5 by another cell (f5) and return the answer Any thoughts? Thanks in advance for your help. Please email any responses Jessica.w@zimshipping.com Hi not sure what &#...

NETWORKDAYS
How do I use the "networkdays" formula to determine when a produc should ship by? I have a PO issue date and a shipment due date, I need to calculate "Should ship by date". I know that it takes 30 days on the water, an I can't include weekends. Help -- ajpower ----------------------------------------------------------------------- ajpowers's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=940 View this thread: http://www.excelforum.com/showthread.php?threadid=27564 On Fri, 5 Nov 2004 09:42:32 -0600, ajpowers <ajpowers.1f991b@exce...

HELP: Search a formula inside of a Cell
I am trying to compare some old spreadsheets and upgrade to the new and have a case in try to determine if a value was added to a formula inside a cell. So I would like to do a search/find on the contents of the FORMULA in the cell. Example: Cell A1 Contains a formula +F12+F34+F67 Is there a function that can search the formula? Example: FIND "F34" in cell A1. Everything I can see so far you can only search the results, not the formula. Thank you in advance for your help!!! Mike formula are strings. Usually I use the FIND in the worksheet menu to locate the form...

Inputting Source Data
I am creating a custom combination chart to display sales data. Bars along the x axis will display actaul sales figures and a line graph will dispay projected sales. I am new to this and am not sure how to enter the data. I have the data on a separate worksheet as you see below (but lined up better). If anyone has suggested regarding how to enter the data formula, I would appreciate it. Apr May Jun Jul Aug Sep Oct Nov Dec Total Actual 6 Projected 2,836 560 800 1,936 8,112 5,412 6,656 3,568 29,880 Thanks, Ali :) :confused: -- foredis -------------------------------------...

Need One Excel Template to copy to TWO Databases
Here's the problem: Right now I have a one template (.xlt) and one excel database (.xls) that works fine. Now I want to create a second database so tha whenever I enter in information into the template, it creates a copy i both excel databases. I could just create a new duplicate database and a duplicate templat but that would require me entering in the information twice. Since enter in a lot of information, this is very undesirable. Anyone please help me figure out how to link one template (.xlt) to excel database files (.xls) Steps already taken: When the template wizard asked ...

Urgent Help with CheckSignature method of SignedXml
Hey Friends, I have a Signed XML that looks like the below I also have the public certificate for this but i am not able to pass the public key of the X509Certificate2 to the CheckSignature method any idea or help? <?xml version="1.0" encoding="UTF-8"?> <B:Envelope xmlns:B="http://schemas.xmlsoap.org/soap/envelope/" xmlns:A="http://www.routeone.com/namespace.messaging.diag#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP:Header xmlns:SOAP-SEC="http://schemas.xmlsoap.org/soap/security/2000-12" xmlns:S...

Customer Sync error....HELP!!!
I was updating a customer in HQ, their billing info. I closed out the client list, then went back into it 5 minutes later and every one of our 10,000 customers now all have the same billing information and extra phone numbers in each customer account. The purchase history is intact as are all the tracking numbers per customer. On top of that, HQ had already sync'd to my other stores and now every store has 10,000 of the same customer. I need help and need it badly and as fast as possible. Anyone have any ideas on how to fix this? ...

Help please with multiple accounts in Exchange
I am setting up Exchange 2003, with Outlook as client software. What I need to do is to be able to accept email for two accounts, shall we say called 1@domain and 2@domain, where BOTH these emails go into the 1@domain Inbox on Outlook, where 1@domain is forwarded to a third party but not 2@domain. Becuase 2@domain is a 'private' box. All email to both accounts needs to be accesible via webmail and blackberry from the one inbox. And I cannot rely on anyone sending email to use codes like 'private' etc. Anyone that can help would be a genius! Thanks in advance. On Fri, 20 Aug...

need formula for multiple columns/rows
I have a spreadsheet with a budget value in column C, monthly billings in columns D - Q, and the remaining balance in column R. I can use =c3-sum(d3:q3) for row 3, but is there a formula to repeat the calculation for multiple rows without having to type that into the R cell on every row. I'm sure it is simple, I'm just learning. Thanks, kzas Hi Kzas, If I got it right, you want the formula to calculate the sum for al the rows from row 3 up to the row is appears. If so, then the followin should do it: =$c$3-sum($d$3:$q3) -(assuming that there is only one budget figure)- =$c$3-su...

Help creating a cost range
I need help creating a cost range for the following scenario. If the value of cell A1 falls between 0-300 I need the following cell A2 to say $0-$300 or if A1 was 389 I would need A2 to say $300-$600 and so on. In need it broke down in $300 increments to $6000. Thank You Try a VLOOKUP. See: http://www.officearticles.com/excel/vlookup_formulas_in_microsoft_excel.htm ************ Anne Troy www.OfficeArticles.com "tysonstone" <tysonstone@discussions.microsoft.com> wrote in message news:4F45699F-5C22-4E4F-98E5-BE246543CCD4@microsoft.com... >I need help creating a cost r...

help : exchange 5.5 DS problem
Hi All, One of my exchange 5.5 site has around 10 servers. On last Friday, I found the DS database of one of exchange servers was damaged so the DS service of the server could not be started. Therefore, I repaired the DS database then I could start the DS service on the exchange. However, from the exchange server's event log, we found the following error message >>Source : MSExchangeDS >>Catalog : internal processing >>Event ID : 1171 >>Message content : Exception e0010004 has occurred with parameters -1601 >>and 323384 (internal ID 208017d). Cont...

Drop down list help #2
Excel 2003I have created a drop down list in a cell(s) and I want the list to show all values with out a scroll bar. The list is not long (maybe 20 values in the end) Anyway to do this? Thanks Dave Only with a combobox....................Data Validation dropdowns are limited to 8 items. Debra Dalgleish has a sample workbook with a 12 item combobox tied to a DV dropdown. Can be easily changed to your 20 items. http://www.contextures.on.ca/excelfiles.html#DV0020 Gord Dibben MS Excel MVP On Tue, 16 Jun 2009 11:36:13 -0700, "Dave" <dcooper@iacnc.edu> wrote: >Exce...

SUMIF Formual help
I have an attendance roster that uses numbers to reflect time spent wit a student. (e.g. 1=30 min, 2=60 min, etc.) This is reflected in 3 columns denoting the days in the month. I need to total the amoun spent each month with a student. My question is do I use a combinatio of SUMIF, nested IFs, or a combination of SUMIF and possibly a VLOOKUP Thank yo -- Message posted from http://www.ExcelForum.com Assume the month is in A2:A32 =SUMPRODUCT(COUNTIF(A2:A32,{1;2}),{30;60}) adapt to fit more requirements -- Regards, Peo Sjoblom (No private emails please, for everyone's benefit k...

I have published a worksheet to the web and it works good but one problem please help
Hello I published a worksheet to the web. The address is http://www.inforamp.com/~kidd/html/pmcshop1.htm The problem is I want to get rid of the scroll bars and the top men bar so ONLY the worksheet is present. Can someone tell me what I did wrong You help is greatly appricated Pau -- kid ----------------------------------------------------------------------- kidd's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1579 View this thread: http://www.excelforum.com/showthread.php?threadid=27378 ...

Need Help (i'm at the end of my rope) WMP wont work Missing DRM
Hello, i konw i'm new here but i'm really at the end of my rope. i had to upgrade my motherboard and processer not long ago, and when i did i seemed to lost my drm folder in windows. i have tried everything i can find online, including upgrading windows vista to windows 7 (no good) show all hidden files to delete all files in drm folder. (no drm folder) went to that upgrade drm thing microsoft has and i cant because the button is greyd out or i get a error in internet explorer. running a reg cleaner for missing dll's. i'm losing it. i need major help. please ...

SBS 2008 problem. Urgent help required.
Hi, I have a small SBS 2008 domain with a big problem. This morning I wanted to change the power strip my server was plugged into. As it has 2 PSU's running from a UPS I thought I'd get away with just unplugging the power strip and changing it for the new one. However, (stupidly) I forgot the switch was also plugged into that same power strip. First, I realised Outlook wasn't connecting the the Exchange server (my SBS server). I Looked on the server and a few of the Exchange services had stopped working. Fair enough, I thought. As there were possible other serv...

Help #12
I have a an excel doc that I need the information entered to be transferred to a log. Each copy of the doc must be saved, so there are about 150 worksheet tabs, each one with a copy of the doc. What I want to do is have the information go to a log sheet as each doc is filled out in order to keep from filling in the information more than once. The problem is that when I enter the formulas to transfer the data, I can't seem to copy and paste into the log without having to edit each formula's sheet reference. The different entries are kept from changing by using the $. Is the...

Is soliciting paid help allowed in the group?
I know that there is strong opposition to "advertising" your services but is the asking for paid help allowed? Wanted to ask before I got myself in trouble with a group that has been a big help to me many times. Thanks in advance dave It's not done very often, but I've seen some posts in the past where people have said they were willing to pay for work to be done. I don't know that that is a problem. However, who / what responds to such requests is then outside anyone's control < g >. There are various forums on the internet where one can post work p...