Показать сообщение отдельно

  #1804  
Старый 09.11.2008, 02:43
ToniKapuchon
Участник форума
Регистрация: 26.02.2006
Сообщений: 209
Провел на форуме:
2418438

Репутация: 93
По умолчанию

Клиент:
PHP код:
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <windows.h>

int _tmain(int argc_TCHARargv[])
{
    
HANDLE hFile;
    
char *servName "\\\\.\\Mailslot\\Laba2", *p;
    
char s[20];
    
s;
    
DWORD d 20;                
    
LPDWORD lp = &d;
    
//открываем существующий файл или создаем новый
    
hFile CreateFile(servNameGENERIC_WRITE FILE_SHARE_READ,
            
NULLOPEN_EXISTINGFILE_ATTRIBUTE_NORMALNULL);
    if(
hFile == INVALID_HANDLE_VALUE)
      
puts("Error server create!!!");
    else
    {
      
puts("Ok server find!!!");
      
puts("Please enter some text in file:");
      
gets(p);
      
//присваиваем концу строки нулевой символ
      
s[strlen(s)]='\0';
      
//запись в файл
      
WriteFile(hFilesstrlen(s), lpNULL);
      
gets(p);
      
CloseHandle(hFile);
    }
    return 
0;

Сервер:
PHP код:
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#include <iostream>
using namespace std;
int _tmain(int argc_TCHARargv[])
{
    
HANDLE pMailslot;
    
char *servName "\\\\.\\Mailslot\\Laba2", *p;
    
char s[5];

    
s;

    
DWORD d 150;
    
LPDWORD lp = &d;
    
pMailslot CreateMailslot(servName0MAILSLOT_WAIT_FOREVERNULL);

    if(
pMailslot == INVALID_HANDLE_VALUE)
      
cout<<"Don't create!!!";
    else
      
cout<<"Create server!!!";
    
    
//считывем из файла 7 байт
    
BOOL res ReadFile(pMailslotp5lpNULL); 
    
cout<<endl;
    
cout<<" Message from client: "<<endl;
    
p[5]='\0';
    
cout<<p<<endl;
    
CloseHandle(pMailslot);
    
int a;
    
cin>>a;

Попробуй ето!! всё рабоать должно!!
 
Ответить с цитированием