Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
How to change display settings: screen resolution, screen refresh rate
Capturing keyboard activity of another application with the Raw Input API (VFP9)
Converting Unicode data from the Clipboard to a character string using a given code page
Enumerating data formats currently available on the clipboard
Copying picture of the active form to the Clipboard using Enhanced Metafile API functions
Enumerating raw input devices attached to the system (keyboard, mouse, human interface device)
How to print FoxPro form
Obtaining current Internet Explorer browser version and UserAgent
GDI+: copying to the Clipboard (a) image of active FoxPro window/form, (b) image file
How to create transparent areas inside a form -- punching holes in the form
FindText -- the hopeless and useless Common Dialog
Creating a clipping region from the path selected into the device context of a form
Disabling mouse and keyboard input for the main VFP window (with the app still running)
Using EnumPrinters function to enumerate locally installed printers
Using the Semaphore object to allow only one instance of VFP application running
Reading VFP settings from the Windows Registry
Enumerating Processes -- WinNT
Retrieving graphic capabilities of default printer
Current keyboard type
How to save registry key including its subkeys and values to a file
Changing file attributes
A procedure for setting file times
Using the DeleteFile
Retrieving Printer Device Context using PrintDlg function
Peer-to-peer LAN messenger built with Mailslot API functions

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Versions:
click to open
Before you begin:
Run this example simultaneously on several computers on a network. All users will be able to exchange plain text messages.

A light-weight solution with no central server, no file sharing, and no access violation, but with automatic user detection.

Note that the communication may require ports 137 to 139 opened on each side. No further configuration is required except the setting a name for the mailslot. Same name have to be used by all participating applications.

A timer control is set to check for inbound messages.

See also:
  • Using mailslots to send messages on the network
  • Using the NetMessageBufferSend to send messages on the network
  • How to create non-blocking Winsock server
  • A client for testing non-blocking Winsock server
  • Using named pipes to pass data between processes
  • Using WM_COPYDATA for interprocess communication
  •  
      Members area. Log in to view this example.
     
      User name:
      Password:
     
     
      Forgot your password?
     
      Sign up for
    the Membership
     
     


    User rating: 0/10 (0 votes)
    Rate this code sample:
    • ~
    8758 bytes  
    Created: 2003-06-06 14:46:00  
    Modified: 2011-12-10 09:20:22  
    Visits in 7 days: 163  
    Listed functions:
    CloseHandle
    CreateFile
    CreateMailslot
    GetLastError
    GetMailslotInfo
    GetTickCount
    ReadFile
    WriteFile
    Printer friendly API declarations
    My comment:
    Mailslot name -- in this sample code "foxapp" -- practically keeps all users together. Any other valid file name is appropriate, except some reserved names like "Messengr", "BROWSER" etc.

    A mailslot with name \\.\mailslot\foxapp is created on each computer. That turns such a computer into server receiving messages sent to this mailslot from other computers.

    A computer name is obtained through SYS(0) function.

    * * *
    On start the Tmsg instance creates a mailslot with a name "foxapp", same name for all users in this group should be used: \\.\maislot\foxapp.

    Then Tmsg broadcasts ONLINE and DETECT messages to all available network computers, using wildcard character * as a destination mailslot name: \\*\mailslot\foxapp.

    On receiving DETECT message any existing Tmsg instance automatically sends ONLINE message back to the sender. That is how the new object gets know who else is online.

    On termination the Tmsg instance broadcasts OFFLINE message to all users -- again the wildcard character is used -- to let everyone know that this user is disconnected.

    Maislots provide no confirmation of receipt. For that reason the Tmsg object on receiving a message automatically sends a confirmation back to the sender.

    For sending a message to another computer -- say with DESK3011 name -- the Tmsg object creates file handle using mailslot name \\DESK3011\Maislot\foxapp, and writes message data to this handle using WriteFile function.

    A message has a simple format:
  • sender - 24 bytes -- local computer name
  • confirmation flag - 1 byte
  • system message flag - 1 byte
  • message body - the rest of the message

    The GetMessages method is invoked on each Timer event checking for incoming messages.
  • Word Index links for this example:
    Translate this page:
      Spanish    Portuguese    German    French    Italian  
    FreeTranslation.com offers instant, free translations of text or web pages.
    User Contributed Notes:
    How to open port 137 to 139 | 2010-06-20 22:41:42
    Please tell me how to open communication port 137 to 139
    Thank You

    Copyright 2001-2014 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

    Privacy policy
    Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.1.68), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
    Last Topics Visited (54.204.200.90)
    5 sec.Example: 'Enumerating MIDI output devices'
    9 sec.
    Function group: 'GDI+ Bitmap'
    10 sec.Function: 'ReleaseDC'
    12 sec.Example: 'How to delete IE cookies, clear IE history and delete files in Temporary Internet Files directory'
    15 sec.Function: 'GetTextExtentPoint32'
    17 sec.Function: 'NetApiBufferSize'
    Function group: 'Network Management'
    21 sec.Example: 'How to Start a Process as Another User (NT/XP/2K)'
    27 sec.Function: 'IsZoomed'
    30 sec.Example: 'The original LoadPicture() function in VFP returns valid handles to bitmaps, icons, cursors, and metafiles'
    34 sec.Function: 'NetUserGetGroups'
    Function group: 'Network Management'
    Google
    Advertise here!