Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Has anyone used SHFileOperation successfully?

400 views
Skip to first unread message

Jim Smith

unread,
Mar 3, 2004, 9:26:31 AM3/3/04
to
I'm trying to use SHFileOperation api call to move and delete files. I'm getting
a memory access error when I call the function. I'm not sure if I have the
structure needed by the function setup correctly.

Here is the structure I created to pass to the function. I pass this function by
ref.

global type struct_shell_file_operations from structure
long lwindowhandle
unsignedinteger laction
blob sfrom
blob sto
integer iflags
boolean lanyoperationsaborted
struct_handle_to_mappings lnamemappings // See structure below
string iprogesstitle
end type

global type struct_shell_name_mapping from structure
string sOldPath
string sNewPath
integer iOldPath
integer iNewPath
end type

For the Blob variables, I use Blob edit to set the values.

Can anyone tell me what is wrong or any info to help me?

I did a search in goole and there wasn't a solution. One of the positng said the
Roy Kiesler had a solution but the solution didn't work for the individual. Roy
can you help me out or give me some pointers?

Jim Smith
Duqusene Light Company
jrsmithATduqlightDOTcom
Pittsburgh, PA USA

Bruce Armstrong [TeamSybase]

unread,
Mar 3, 2004, 9:46:07 AM3/3/04
to
They're probably referring to:

http://www.pfcguide.com/extensions/ext_0014.asp

On 3 Mar 2004 06:26:31 -0800, "Jim Smith" <jrs...@duqlight.com>
wrote:

Bruce Armstrong [TeamSybase]
http://www.teamsybase.com

Sixth Annual Sybase Tools Seminar - April 19 - Minneapolis, MN
http://www.powerobjects.com/seminar/?source=newsgroups

Two new books on developing with PowerBuilder
http://www.pb9books.com?source=newsgroups

Need code sample? Check out CodeXchange:
http://www.codexchange.sybase.com

ISUG Enhancement Requests
http://www.isug.com/cgi-bin/ISUG2/submit_enhancement

Preach the gospel at all times. If necessary, use words. - Francis of Assisi
http://www.needhim.org

philip_salgannik

unread,
Mar 3, 2004, 10:39:19 AM3/3/04
to
This worked for me:
type os_shfileopstruct from structure
unsignedlong hwnd
unsignedlong wfunc
blob pfrom
blob pto
unsignedinteger fflags
unsignedlong banyoperationsaborted
unsignedlong hnamemappings
string lpszprogresstitle
end type

//inside a function call:
// Arguments: as_SourceFile - the file(s) to delete.
// aui_flags - file operation flags (0 -
default)
// aw_requestor - the requesting window


os_shfileopstruct lstr_FileOp
Integer li_rc

lstr_FileOp.hWnd = Handle(aw_requestor)
lstr_FileOp.wFunc = FO_DELETE
lstr_FileOp.pFrom = Blob( as_SourceFile +
Space(2) )
BlobEdit( lstr_FileOp.pFrom, Len( as_sourcefile ) + 1,
Char(0) )
BlobEdit( lstr_FileOp.pFrom, Len( as_sourcefile ) + 2,
Char(0) )
lstr_FileOp.fFlags = aui_flags
lstr_FileOp.hNameMappings = 0
lstr_FileOp.lpszProgressTitle = Space(10)

li_rc = SHFileOperationA( lstr_FileOp )
IF li_rc <> 0 THEN
IF NOT IsNull( lstr_FileOp ) THEN
IF lstr_FileOp.bAnyOperationsAborted = 1 THEN
RETURN 0
END IF
END IF
ELSE
-1
END IF

RETURN 1

Jim Smith

unread,
Mar 3, 2004, 11:09:27 AM3/3/04
to
Thanks Philip. Thats what I needed. The structure I defined was incorrect. Works
perfect.

On 3 Mar 2004 07:39:19 -0800,
in sybase.public.powerbuilder.general

0 new messages