Announcement

Collapse
No announcement yet.

Network Apps

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Peter Redei
    replied
    Code:
    'I am using this very simple code
    'testing and allowing access:
    IF AllowAccess(limit, %False) THEN 
    	'user can 
    else
    	'user can not
    end if
    'release when the user exists
    AllowAccess 0, %True
    
    'this is the only code 
    FUNCTION AllowAccess(lNumUsers AS LONG, bRelease AS INTEGER) AS INTEGER
    
        FUNCTION = %True
        ON ERROR RESUME NEXT
        IF bRelease THEN
            UNLOCK #lLockHandle, lLockPos
            CLOSE lLockHandle
            EXIT FUNCTION
        END IF
        DIM aFile$, lLen AS LONG, l AS LONG, a$
    
        lLockHandle = FREEFILE
        'give value to aFile$ on the network before going farther
        aFile$ = 
        OPEN aFile$ FOR BINARY SHARED AS lLockHandle
        lLen = LOF(lLockHandle)
        a$ = " "
        FOR l = 1 TO lLen
            ERR = 0
            GET #lLockHandle, l, a$
            IF ERR = 0 THEN
               LOCK #lLockHandle, l
               IF ERR = 0 THEN
                   lLockPos = l
                   EXIT FUNCTION
               END IF
           END IF
        NEXT
        DO
           ERR = 0
           lLen = lLen + 1
           IF lLen > lNumUsers THEN
                 CLOSE #lLockHandle
                 FUNCTION = %False
                 EXIT FUNCTION
           END IF
           PUT #lLockHandle, lLen, a$
           IF ERR = 0 THEN
               LOCK #lLockHandle, lLen
               IF ERR = 0 THEN
                  lLockPos = l
                  EXIT FUNCTION
               END IF
           END IF
        LOOP
    END FUNCTION
    ------------------

    Leave a comment:


  • Scott Turchin
    replied
    Er, Do you mean from a client machine you wish to check?

    You would have to make it a service, call it from another workstation as a service, or use some sort of SNMP type thing, or use that Mutex method with a license type app running as a server to send the info back to you?


    Interesting...

    Scott

    ------------------
    Scott

    Leave a comment:


  • Scott Turchin
    replied
    Why not use mutex's?
    IE create a mutex, if it fails increment one:
    Code:
    Local hMutex As Long
    Local lLoop  As long
    For lLoop = 1 to 25
       lpClassName = "PROGRAM" & Str$(lLoop) 'PROGRAM1, PROGRAM2
       hMutex = CreateMutex(ByVal %Null, 0, lpclassName)
       If GetLastError <> %ERROR_ALREADY_EXISTS Then Exit Loop Else CloseHandle hMutex
    Next
    'Don't forget to close at end of program:
    CloseHandle hMutex
    ------------------
    Scott

    [This message has been edited by Scott Turchin (edited April 29, 2001).]

    Leave a comment:


  • Jim Seekamp
    replied
    Yes, that is the approach I am currently using, but I'm wondering if there is a more orthodox way of doing it through Windows.

    Best Regards

    Jim


    ------------------
    Jim Seekamp

    Leave a comment:


  • Charles K. Kincaid
    Guest replied
    You need some type of license server. This can be a data file.
    Each copy gets its MAC address and then opens the file. One MAC addrress per record.
    The program reads the file looking for a match. If found, stop looking. This copy is registered.
    Else add your record to the end of the file.

    Your program could limit the number of records in the file. No more than 25 records lets say.

    Even if they delete the security file, it won't matter. The same 25 addresses will just re-register.

    If you want the count of copies running at the same time, that is harder.

    You'd have to write a server program that the copies would log into.
    After so many connections, refuse more.


    ------------------
    ATB

    Charles Kincaid

    Leave a comment:


  • Jim Seekamp
    started a topic Network Apps

    Network Apps

    I need to count the instances of my app running on the server if my app is running the program off the server.
    Is there any way of doing that, since enumwindows only seems to enumerate the apps on the current machine?

    Best Regards

    Jim



    ------------------
    Jim Seekamp
Working...
X