How do I execute Win32 functions?

Learning APL or new to Dyalog? Ask "silly" questions here, without fear...

How do I execute Win32 functions?

Postby rex on Wed Jul 26, 2023 9:51 pm

How do I execute Win32 functions?
For instance, in APL+Win I can execute the Windows GetTempPath function to query the user's temp directory with:
      ⎕WCALL 'GetTempPath' 128 (128⍴⎕TCNUL)  
32 C:\Users\rex\AppData\Local\Temp\

How does one do this in Dyalog?

(I am a very experienced APL programmer, but new to Dyalog.)
rex
 
Posts: 12
Joined: Sat Jun 10, 2023 10:49 pm

Re: How do I execute Win32 functions?

Postby JoHo on Thu Jul 27, 2023 3:20 pm

Hi Rex,
this would be ⎕NA, for Name Association
There is a QuadNA.dws with examples in the namespace Windows.
Greetings,
JoHo
User avatar
JoHo
 
Posts: 37
Joined: Sat Nov 28, 2009 12:51 pm
Location: Austria, EU

Re: How do I execute Win32 functions?

Postby rex on Thu Jul 27, 2023 3:31 pm

Thanks a lot -- that will get me started.
rex
 
Posts: 12
Joined: Sat Jun 10, 2023 10:49 pm

Re: How do I execute Win32 functions?

Postby JoHo on Thu Jul 27, 2023 3:41 pm

copied from the ⎕NA docu, "more examples":

Code: Select all
      ⎕←GetTempDir''
C:\Users\Alpha\AppData\Local\Temp\

      ⎕VR'GetTempDir'
     ∇ {temp}←GetTempDir dummy;get;size
[1]    'get'⎕NA'U4 kernel32|GetTempPath*   U4 >0T' ⍝
[2]    (size temp)←get 128 128
     ∇

User avatar
JoHo
 
Posts: 37
Joined: Sat Nov 28, 2009 12:51 pm
Location: Austria, EU

Re: How do I execute Win32 functions?

Postby petermsiegel on Fri Jul 28, 2023 3:53 am

Of course, for this specific example, there's
Code: Select all
   739⌶0   ⍝ Return temporary dir name on this o/s
/tmp
and there's ⎕SH (or ⎕CMD, the Windows-style name) to execute relatively arbitrary host O/S commands.
petermsiegel
 
Posts: 160
Joined: Thu Nov 11, 2010 11:04 pm

Re: How do I execute Win32 functions?

Postby PGilbert on Fri Jul 28, 2023 2:06 pm

If you don't mind using .Net here is what I am using:

To start a Win32 function:
Code: Select all
⎕USING∪←⊂',System.dll'
sink←System.Diagnostics.Process.Start(⊂'notepad.exe')
sink←System.Diagnostics.Process.Start(⊂'calc.exe')
sink←System.Diagnostics.Process.Start(⊂'C:\Program Files (x86)\Dyalog')


To get the TempPath:
Code: Select all
⎕USING∪←⊂',mscorlib.dll'
System.IO.Path.GetTempFileName
User avatar
PGilbert
 
Posts: 440
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How do I execute Win32 functions?

Postby rex on Sat Jul 29, 2023 10:07 pm

Ha ha -- the usual APL situation:
many possible solutions, quite different from each other.
Thank you, everyone.
rex
 
Posts: 12
Joined: Sat Jun 10, 2023 10:49 pm


Return to New to Dyalog?

Who is online

Users browsing this forum: Google [Bot] and 1 guest