Recent

Author Topic: How to use this code in unicode.  (Read 7716 times)

nocuttree

  • New Member
  • *
  • Posts: 36
How to use this code in unicode.
« on: October 25, 2014, 05:19:36 pm »
I have used this code:
Code: [Select]
runfile:='C:\tên.exe';
if ShellExecute(0,nil,PChar(runfile),PChar(''),nil,1) =0 then;]
I want to open C:\tên.exe by this code but it don't run.
Thanks to all!
Sorry my English, Windows xp, Lazarus 1.2.2!

hy

  • Full Member
  • ***
  • Posts: 221
Re: How to use this code in unicode.
« Reply #1 on: October 25, 2014, 05:32:34 pm »
i don't know whether this can work in windows at all... but you need to declare at least your filename as widestring and not as string:
Code: [Select]
var
   runfile : widestring;
_____
***hy
OS: debian sid(64bit)  [fpc 3.20] Lazarus 2.0.12

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: How to use this code in unicode.
« Reply #2 on: October 25, 2014, 05:33:53 pm »
Use Utf8ToSys(runfile) in the call to ShellExecute, or use TProcessUtf8 instead.

Bart

nocuttree

  • New Member
  • *
  • Posts: 36
Re: How to use this code in unicode.
« Reply #3 on: October 25, 2014, 07:50:05 pm »
Use Utf8ToSys(runfile) in the call to ShellExecute, or use TProcessUtf8 instead.

Bart
i don't know whether this can work in windows at all... but you need to declare at least your filename as widestring and not as string:
Code: [Select]
var
   runfile : widestring;

Thanks you!
I have tried this code:
Code: [Select]
var runfile : widestring;
if ShellExecute(0,nil,PChar(utf8tosys(runfile)),PChar(''),nil,1) =0 then;
But it is not works :(
Sorry my English, Windows xp, Lazarus 1.2.2!

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: How to use this code in unicode.
« Reply #4 on: October 25, 2014, 09:01:26 pm »
Code: [Select]
if ShellExecute(0,nil,PChar(utf8tosys(runfile)),nil,nil,1) =0 then;try this one
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: How to use this code in unicode.
« Reply #5 on: October 26, 2014, 10:46:28 am »

Change string to widestring, and assign all string variables to widestring. Then typecast them to pwidechar and call shellexecuteW instead of shellexecute.


nocuttree

  • New Member
  • *
  • Posts: 36
Re: How to use this code in unicode.
« Reply #6 on: October 26, 2014, 01:44:50 pm »
Code: [Select]
if ShellExecute(0,nil,PChar(utf8tosys(runfile)),nil,nil,1) =0 then;try this one
I have tried.
Sorry my English, Windows xp, Lazarus 1.2.2!

nocuttree

  • New Member
  • *
  • Posts: 36
Re: How to use this code in unicode.
« Reply #7 on: October 26, 2014, 02:19:36 pm »

Change string to widestring, and assign all string variables to widestring. Then typecast them to pwidechar and call shellexecuteW instead of shellexecute.
I have tried this code but it doesn't works:
Code: [Select]
if ShellExecutew(0,nil,PwideChar('C:\tên.exe'),PWideChar(''),nil,1) =0 then; 
Sorry my English, Windows xp, Lazarus 1.2.2!

hy

  • Full Member
  • ***
  • Posts: 221
Re: How to use this code in unicode.
« Reply #8 on: October 26, 2014, 02:33:48 pm »
I would strongly recommend not using other characters than 23..127 for filenames with Windows.
Did you try it uppercase????
_____
***hy
OS: debian sid(64bit)  [fpc 3.20] Lazarus 2.0.12

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: How to use this code in unicode.
« Reply #9 on: October 26, 2014, 03:03:39 pm »
Did you try it uppercase????
Using ShellExecuteW, right?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: How to use this code in unicode.
« Reply #10 on: October 26, 2014, 03:59:02 pm »

Change string to widestring, and assign all string variables to widestring. Then typecast them to pwidechar and call shellexecuteW instead of shellexecute.
I have tried this code but it doesn't works:
Code: [Select]
if ShellExecutew(0,nil,PwideChar('C:\tên.exe'),PWideChar(''),nil,1) =0 then; 

Change string to widestring, and assign all string variables to widestring Use utf8decode if necessary.

so
Code: [Select]
var s :widestring;
  s:=utf8decode('c:\withaccentswhatever');
  shellexecutew (..., pwidechar(s)....);

nocuttree

  • New Member
  • *
  • Posts: 36
Re: How to use this code in unicode.
« Reply #11 on: October 27, 2014, 01:14:59 pm »
Did you try it uppercase????
Using ShellExecuteW, right?
Not different.
Sorry my English, Windows xp, Lazarus 1.2.2!

nocuttree

  • New Member
  • *
  • Posts: 36
Re: How to use this code in unicode.
« Reply #12 on: October 27, 2014, 01:16:43 pm »

Change string to widestring, and assign all string variables to widestring. Then typecast them to pwidechar and call shellexecuteW instead of shellexecute.
I have tried this code but it doesn't works:
Code: [Select]
if ShellExecutew(0,nil,PwideChar('C:\tên.exe'),PWideChar(''),nil,1) =0 then; 

Change string to widestring, and assign all string variables to widestring Use utf8decode if necessary.

so
Code: [Select]
var s :widestring;
  s:=utf8decode('c:\withaccentswhatever');
  shellexecutew (..., pwidechar(s)....);
It have run.
« Last Edit: October 27, 2014, 01:20:01 pm by nocuttree »
Sorry my English, Windows xp, Lazarus 1.2.2!

nocuttree

  • New Member
  • *
  • Posts: 36
Re: How to use this code in unicode.
« Reply #13 on: October 27, 2014, 01:17:46 pm »

Change string to widestring, and assign all string variables to widestring. Then typecast them to pwidechar and call shellexecuteW instead of shellexecute.
I have tried this code but it doesn't works:
Code: [Select]
if ShellExecutew(0,nil,PwideChar('C:\tên.exe'),PWideChar(''),nil,1) =0 then; 
Did you try it uppercase????
Using ShellExecuteW, right?
I would strongly recommend not using other characters than 23..127 for filenames with Windows.
Did you try it uppercase????

Change string to widestring, and assign all string variables to widestring Use utf8decode if necessary.

so
Code: [Select]
var s :widestring;
  s:=utf8decode('c:\withaccentswhatever');
  shellexecutew (..., pwidechar(s)....);
Thanks you!
« Last Edit: October 27, 2014, 01:19:30 pm by nocuttree »
Sorry my English, Windows xp, Lazarus 1.2.2!

 

TinyPortal © 2005-2018