1. Launching files/urls

When using Linux and GTK, almost any file or web address can be 'opened' with the default prog. (or executed) by simply calling show_uri().

Is there a similar call for Windows?

new topic     » topic index » view message » categorize

2. Re: Launching files/urls

irv said...

When using Linux and GTK, almost any file or web address can be 'opened' with the default prog. (or executed) by simply calling show_uri().

Is there a similar call for Windows?

Closest I can think of is calling ShellExecute() with the "open" command:

ShellExecute(handle, "open", <fully_qualified_path_to_folder>, NULL, NULL, SW_SHOWNORMAL); 

https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153(v=vs.85).aspx

new topic     » goto parent     » topic index » view message » categorize

3. Re: Launching files/urls

With OpenEuphoria 4, you can also use pipes:

include std/pipeio.e 
 
public function execCommand(sequence cmd) 
  sequence s = "" 
  object z = pipe:create() 
  object p = pipe:exec(cmd, z) 
  if atom(p) then 
    printf(2, "Failed to exec() with error %x", pipe:error_no()) 
    pipe:kill(p) 
	return -1 
  end if 
  object c = pipe:read(p[pipe:STDOUT], 256) 
  while sequence(c) and length(c) do 
    s &= c 
    if atom(c) then 
	  printf(2, "Failed on read with error %x", pipe:error_no()) 
      pipe:kill(p) 
	  return -1 
    end if 
    c = pipe:read(p[pipe:STDOUT], 256) 
  end while 
  --Close pipes and make sure process is terminated 
  pipe:kill(p) 
  return s 
end function 

Jean-Marc

new topic     » goto parent     » topic index » view message » categorize

4. Re: Launching files/urls

Thanks. It seems like system("explorer " & uri) will work.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Launching files/urls

irv said...

Thanks. It seems like system("explorer " & uri) will work.

That feels a bit hacky to me. Doesn't pass the smell test. ShellExecute would be the correct method.

I provided a complete wrapper in my startw example: http://openeuphoria.org/forum/m/125333.wc

-Greg

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu