Conversion of LPWSTR TO long

During my session i have some doubt on the below code

len1 = GetWindowTextLength(hwndEdit1) + 1;
GetWindowText(temp1, text1, len);
len2=GetWindowTextLength(hwndEdit2)+1;
GetWindowText(temp2, text1, len);


The two variables temp2 and temp1 are LPWSTR so calculate the sum of two variables i need to convert them into long can you help me convert it,
Last edited on
Last edited on
Before Disch gets in, I may as well say it: GetWindowText doesn't necessarily accept wide strings. It might accept normal strings if your compiler settings are different.

There are two functions
GetWindowTextA <- asci: accepts ASCII LPSTR
GetWindowTextW <- unicode accepts Wide LPWSTR

GetWindowText becomes GetWindowTextW if wide characters are enabled, and GetWindowTextA otherwise.

Instead, you should use TCHAR and LPTSTR. It automatically takes on the form of wide or non wide as appropriate. Then the function to use is _ttol().
Last edited on
I wanted to link to that, but couldn't find it...
closed account (zwA4jE8b)
also I noticed that you define 'len1' and 'len2' but in your GetWindowText parameters you just use 'len'
is that supposed to be?
Thank you all for your kind support I am a beginner so I am not using standard coding format so len1, len2, are two names given to a variable. Do you need the full code to solve the problem?
if it is essential i will provide it here for you.
Last edited on
Topic archived. No new replies allowed.