Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #2453

Re: Dbfilespec:Create()

From Mathias <mathias.hakansson@consultec.se>
Newsgroups comp.lang.clipper.visual-objects
Subject Re: Dbfilespec:Create()
Date 2011-11-17 00:06 -0800
Organization http://groups.google.com
Message-ID <27150712.382.1321517204930.JavaMail.geo-discussion-forums@yqoo7> (permalink)
References <02581712-c11e-42b7-ac77-96cab9cfdd29@w1g2000vba.googlegroups.com>

Show all headers | View raw


When I'm using temporary files I create a new subdirectory in the users temp folder.

-----------------------------
function CreateTempDirectory2() as string
	local lpBuffer,ps	as psz
	local foldername		as string
	local r				as int
	local lFailed		as logic
	local dwret			as dword
	
    lpBuffer := MemAlloc(1024)

    dwRet := GetTempPath(1024,lpBuffer)
	do case
		case dwRet == 0
			InfoBox{,GetSystemMessage(GetLastError()),"GetTempPath failed"}:Show()
			lFailed := true
		case dwRet > 1024
			InfoBox{,"GetTempPath failed","Path longer than buffer"}:Show()
			lFailed := true
	endcase

	if lFailed
		foldername := GetEnv("WINDIR") + "\temp\"
	else
		foldername := Psz2String(lpBuffer)
	endif

	foldername += CreateaUniqueKey()
	
	ps := StringAlloc(foldername)
    r := DirMake(ps)	// Create folder
  	MemFree(ps)

	if r != 0
  		InfoBox{,DosErrString(dword(r)),"Cannot create folder " + foldername}:Show()
  	endif

    MemFree(lpBuffer)

    return foldername
--------------------------------
function CreateaUniqueKey as string pascal
	local Guid_New	is _winGuid
	local hr		as long
	local lpBuffer	as psz
	local sGuid		as string

	hr			:= CoCreateGuid(@GUID_New)
	lpBuffer	:= MemAlloc(255)
	hr			:= StringFromGUID2(@Guid_new,lpBuffer,255)
	sGuid		:= Mem2String(lpBuffer,dword(hr*2))    // Unicode: char = 2 bytes
	MemFree(lpBuffer)
	sGuid		:= Wide2Multi(sGuid)     // Undocumented in VO runtime
	
	return sGuid
----------------

When I don't need the directory I can delete it;

--------------------------
if !Empty(self:sPath)
		afiles := Directory(self:spath + "*.*")
		l := ALen(afiles)
		for i := 1 upto l
			DeleteFile(self:sPath + afiles[i,F_NAME])
		next
		
		ApplicationExec(EXECWHILEEVENT)
		
		buf := StringAlloc(self:sPath)
		DirRemove(buf)
		MemFree(buf)
	endif
--------------------------

I create the temporarry dbf:s with my method "DBUndersok" (DBExamine). https://groups.google.com/forum/?hl=sv#!searchin/comp.lang.clipper.visual-objects/dbundersok/comp.lang.clipper.visual-objects/C3O4tgRj6sM/X46hBvfa_aMJ

This has been working very well in all versions of Windows (XP and later).

/Mathias

Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Dbfilespec:Create() Lucas_be <lucas_be@advalvas.be> - 2011-11-15 08:19 -0800
  Re: Dbfilespec:Create() "Stephen Quinn" <stevejqNO@bigpondSPAM.net.au> - 2011-11-16 14:16 +1100
    Re: Dbfilespec:Create() "richard.townsendrose" <richard.townsendrose@gmail.com> - 2011-11-16 01:40 -0800
  Re: Dbfilespec:Create() Mathias <mathias.hakansson@consultec.se> - 2011-11-17 00:06 -0800
    Re: Dbfilespec:Create() Lucas_be <lucas_be@advalvas.be> - 2011-11-17 01:48 -0800
      Re: Dbfilespec:Create() Szepi <szepligeti@gmail.com> - 2011-11-17 05:39 -0800
      Re: Dbfilespec:Create() dlzc <dlzc1@cox.net> - 2011-11-17 06:45 -0800
        Re: Dbfilespec:Create() "richard.townsendrose" <richard.townsendrose@gmail.com> - 2011-11-23 05:20 -0800

csiph-web