convert a variable

Hi to all.
Im very new to any sort of programing, so please dont laugh at my naivity.

I have some code that returns a long type variable.
Another part of the code needs that variable but as LPCWSTR.

Would anyone be so kind as to demonstrate how to do this please.

I have read about type casting but I am having much trouble understanding it, I feel so dumb.
Post your code. Do you need to convert a long to string?
Your going to have to elaborate on what you need to do. Do you want to convert a long to a string so that you can display that string with the number in it?
Sorry, I did not post code, or maybe even explain properly.

here is my code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <Windows.h>
#include "test.h"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	
	Sleep(1000);
	TES_Run(L"notepad.exe", L"", 1); //start notepad
	TES_WaitWindow(L"Untitled - Notepad", L"", 0); //wait for the window to appear
	TES_Send(L"Hiya World", 0); //write some tesxt to the notepad edit control

	
	char szText[1024];
	TES_GetSBText(L"Untitled - Notepad", L"", 2, szText, 1024); // retreive text from status bar
	MessageBox(NULL, szText, "Text:", MB_OK); // show the text

	return 0;
}


My problem is this line "TES_GetSBText(L"Untitled - Notepad", L"", 2, szText, 1024); " specificaly the underlined part, it is intellisense error...


char szText[1024]

Error: argument of type "char*" is incompatible with paramater of type "LPWSTR"


Here is the header, test.h just incase its needed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef __TEST_H
#define __TEST_H

#ifdef __cplusplus
	#define TES_API extern "C"
#else
	#define TES_API
#endif

#define TES_INTDEFAULT (-2147483647)

TES_API void WINAPI TES_Init(void);
TES_API long TES_error(void);


TES_API long WINAPI TES_Run(LPCWSTR szRun, /*[in,defaultvalue("")]*/LPCWSTR szDir, /*[in,defaultvalue(1)]*/long nShowFlags);
TES_API long WINAPI TES_WaitWindow(LPCWSTR szTitle, /*[in,defaultvalue("")]*/LPCWSTR szText, /*[in,defaultvalue(0)]*/long nTimeout);
TES_API void WINAPI TES_Send(LPCWSTR szSendText, /*[in,defaultvalue("")]*/long nMode);
TES_API void WINAPI TES_GetSBText(LPCWSTR szTitle, /*[in,defaultvalue("")]*/LPCWSTR szText, /*[in,defaultvalue(1)]*/long nPart, LPWSTR szStatusText, int nBufSize);


#endif 


I would be glad if someone could help me out with this.
Thanks for looking.

edit

I am using VC++ Visual Studio 2010.


Last edited on
Since you are compiling your application in UNICODE you need to change char to wchar_t

wchar_t szText[1024];
Thany you so much for your reply binarybob350.

But unfortunately this swaps one error to the other :(
The error on the line previously posted goes away but a new one turns up on the line below.

"MessageBox(NULL, szText, "Text:", MB_OK);"


wchar_t szText[1024]

Error: argument of type "wchar_t*" is incompatible with paramater of type "LPCSTR"


Notice its not crying about LPWSTR anymore, but crying about LPCSTR.

I am into my 4th day of trying to solve this problem now, its quite frustrating.
Try MessageBoxW instead.
Of course m4ster r0shi, thank you very much, that solves my problem.

No just to find how to make my own string for the title bar now as "Text:" becomes incompatible :(.

Thank you once again, Im quite delighted. :)
L"Text:"
I had become so confused with my fault, I never even seen that (something I first had to get over earlier in my project).

Thank you again m4ster r0shi sugar, I really apreciate the help, and all who replied.

What an excellent resource this forum is, I cannot thank you all enough.

Suz.
Suzie wrote:
m4ster r0shi sugar

Stop it... I'm blushing...
Topic archived. No new replies allowed.