1. tutor3.exw problems answered...

To answer my own question, regarding tutor3.exw file finding problem.
I finally put QuickView back on my 'puter.
Thanks to Daniel Berstein for his guidance blink

-- current.ew -- returns current directory of calling program.

include machine.e
include dll.e

global function GetCurrentDir()
  sequence CurrentDir
  atom kernel32, buffer
  integer GetCurrentDirectory, i

  -- Open kernel32.dll
  kernel32 = open_dll("kernel32.dll")
  if kernel32 = 0 then
    puts(1,"Couldn't open kernel32.dll!\n")
    return ""
  end if

  -- Link GetCurrentDirectory procedure
  GetCurrentDirectory = define_c_proc(kernel32,
                       "GetCurrentDirectoryA", {C_INT, C_POINTER})
  if GetCurrentDirectory = -1 then
    puts(1, "GetCurrentDirectory not found!\n")
    return ""
  end if

  -- Allocate buffer for total path
  buffer = allocate(128)

  -- Call procedure
  c_proc(GetCurrentDirectory, {128, buffer})

  -- Read buffer into sequence
  CurrentDir = ""
  i = 0
  while peek(buffer+i) != 0 do
    CurrentDir = CurrentDir & peek(buffer+i)
    i = i+1
  end while

  -- Free allocated buffer
  free(buffer)

  -- Return current directory
  return CurrentDir
end function

-- end current.ew

http://www.king.igs.net/~wolfritz     ...www.king.igs.net/~wolfritz/tutor.htm

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu