473,466 Members | 1,313 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

WindowsXP FileMapping problem

14 New Member
hello,
When I want to use the shared memory, I got a problem.
1.I wrote a server to create a piece of shared memory. Source is below:
// shmsv.cpp
HANDLE hMapFile = NULL;
LPVOID pVoid = NULL;

hMapFile = CreateFileMapping(
INVALID_HANDLE_VALUE,
NULL,
PAGE_READWRITE,
0,
BUF_SIZE, // 1024
SHM_NAME);



pVoid = MapViewOfFile(hMapFile,
FILE_MAP_ALL_ACCESS,
0,
0,
BUF_SIZE);

memset(pVoid, '*', BUF_SIZE);
char *szMsg = "Hello shared memory.";
CopyMemory(pVoid, szMsg, strlen(szMsg));

2.I wrote another program to read message from the shared memory. Source is below:
// readFrom.cpp
HANDLE hFileMap = NULL;
LPVOID pVoid = NULL;

hFileMap = OpenFileMapping(FILE_MAP_READ,
FALSE,
SHM_NAME);

pVoid = MapViewOfFile(hFileMap,
FILE_MAP_READ,
0,
0,
8);
//BUF_SIZE);
printf("message from shared memory is: %s.\n", (char *)pVoid);

3.Here comes the probelm: I only want to output the 8 bytes' info from the shared memory.
But the "readFrom" program outputed all the message from the shared memory.

4.If I only want to output the 8 bytes' info from the shared memory, what should I do?

regards,
yogo
Jan 26 '10 #1
0 1091

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Vishnu | last post by:
I have a strange problem on WindowsXP proffessional with IE6 ,when i try to display a tiff file ,it is not showing ,small red x is comming up. I tried by dowloading latest IE from microsoft but...
1
by: Alex | last post by:
Hi I have been planning to move over to .net for some time now but I have a lot of code written in VB that uses a lot of win32 api's. The main area is reading and writing data quickly to and...
3
by: Kirk Quinbar | last post by:
hi, I have the following sample .NET 1.0 code which converts a metafile to a bitmap: Dim tmpImage As Bitmap 'System.Drawing.Image Dim streamX As New System.IO.MemoryStream() Dim fs As...
2
by: Keyser | last post by:
On most my pages, I use Javascript to play a sound. It works fine in Netscape 4.7, Netscape 7.2, Firefox 1.0, IE5 and IE6 using Windows98 as the operating system. However, using WindowsXP as the...
1
by: Ton | last post by:
I hope someone can help. A few years ago I built an access97 database and program. It ran fine in a setup with 4 users. Earlier this week they upgraded everything to WindowsXP. The access...
2
by: Daniel Danilin | last post by:
Hi, is there any plans to make "WindowsXP Peer-To-Peer SDK" for .NET Framework?
1
by: Dean Slindee | last post by:
Would like to use WindowsXP graphics themes (like shaded tab page in tab control), but am using Windows 2000 operating system. Using Visual Studio 2005 and .Net Framwork 2.0. Have the option...
5
by: Andrius B. | last post by:
I am a newbe in ASP programing. The main problem is: On WindowsXP Professional (SP2) I have installed IIS with all components, I could manage them through "Administrative tolls" in Conrol Panel...
1
by: mmijic | last post by:
First of all my English is not too good so please try to understand me. Thanks I have a major problems with the installation of MS .NET Framework v1.1 on WindowsXP with SP2. Everytime I try to...
1
by: shivapadma | last post by:
hello, 1: what are the advantages of windowsxp over windows2000 2:can we able to open an application of windows2000 in windowsxp
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.