How do I execute Win32 functions?

Learning APL or new to Dyalog? Ask "silly" questions here, without fear...
Post Reply
rex
Posts: 12
Joined: Sat Jun 10, 2023 10:49 pm
Contact:

How do I execute Win32 functions?

Post by rex »

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.)
User avatar
JoHo
Posts: 37
Joined: Sat Nov 28, 2009 12:51 pm
Location: Austria, EU

Re: How do I execute Win32 functions?

Post by JoHo »

Hi Rex,
this would be ⎕NA, for Name Association
There is a QuadNA.dws with examples in the namespace Windows.
Greetings,
JoHo
rex
Posts: 12
Joined: Sat Jun 10, 2023 10:49 pm
Contact:

Re: How do I execute Win32 functions?

Post by rex »

Thanks a lot -- that will get me started.
User avatar
JoHo
Posts: 37
Joined: Sat Nov 28, 2009 12:51 pm
Location: Austria, EU

Re: How do I execute Win32 functions?

Post by JoHo »

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
     ∇

petermsiegel
Posts: 159
Joined: Thu Nov 11, 2010 11:04 pm

Re: How do I execute Win32 functions?

Post by petermsiegel »

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.
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?

Post by PGilbert »

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
rex
Posts: 12
Joined: Sat Jun 10, 2023 10:49 pm
Contact:

Re: How do I execute Win32 functions?

Post by rex »

Ha ha -- the usual APL situation:
many possible solutions, quite different from each other.
Thank you, everyone.
Post Reply