Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / October 2005



Tip: Looking for answers? Try searching our database.

Share FileHandle

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Christoph Basedau - 23 Oct 2005 01:04 GMT
Hi

I'd like to let my dll write into the clients logfile.
using this code:

'# client-side:

    Private f%
    Private mySrv As MyProj.MyCls

    f = FreeFile(1)
    Open "c:\data\test.log" For Append Access Write Shared As #f
    Set mySrv = New MyProj.MyCls
    mySrv.LogFileHandle = f

'# server-side, MyCls.cls

    Private m_hndLogFile%

    Public Property Let LogFileHandle(newHandle As Integer)
        m_hndLogFile = newHandle
    End Property

    ..
    .

    Print #m_hndLogFile, "some text"

Any Time i try to Print sth into the file, i get an error (5, invalid argument)
(or Err 52: invalid filename or number, if i use FreeFile(0))

I tried all different kinds of lock/share-modes also changed FreeFile(1) to
FreeFile(0) or a constant number, but with no luck.
it seems impossible to get write-access to the logfile from the dll-project.
The file itself has no attributes set. Any hints, work-arounds?

Signature

Gruesse, Christoph

Rio Riay Riayo - Gordon Sumner, 1979

Tony Proctor - 24 Oct 2005 13:17 GMT
You can't share the numeric file handle across different processes. However,
they can each open the file concurrently - assuming they can both see the
same file. Passing the file name in UNC format (e.g. \\machine\share\file)
between your client and server is recommended here as drive letters are
machine specific.

Try this code for shared write access to a log file instead:
http://groups.google.ie/group/microsoft.public.vb.com/msg/e2e67b2bdfc0ae5b?hl=en&

   Tony Proctor

> Hi
>
[quoted text clipped - 31 lines]
> it seems impossible to get write-access to the logfile from the dll-project.
> The file itself has no attributes set. Any hints, work-arounds?
Christoph Basedau - 27 Oct 2005 14:11 GMT
24.10.2005 14:17, Tony Proctor schrieb:

> You can't share the numeric file handle across different processes. However,
> they can each open the file concurrently - assuming they can both see the
[quoted text clipped - 6 lines]
>
>     Tony Proctor

Thanks a lot Tony,

Your example using CreateFile, WriteFile, SetFilePos etc, is quite amazing.

I thought i had read somewhere that FreeFile(1) results in file handle
that is generally accessible for other processes (in the case of inproc-server
this shouldn't even be necessary..., because it 'lives' in the same process)
I changed the code now so that all modules share the same
ErrorHandler-object, that treats the file handle as its private
var.

Signature

Gruesse, Christoph

Rio Riay Riayo - Gordon Sumner, 1979

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.