473,609 Members | 2,157 Online
Bytes | Software Development & Data Engineering Community
+ 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 = CreateFileMappi ng(
INVALID_HANDLE_ VALUE,
NULL,
PAGE_READWRITE,
0,
BUF_SIZE, // 1024
SHM_NAME);



pVoid = MapViewOfFile(h MapFile,
FILE_MAP_ALL_AC CESS,
0,
0,
BUF_SIZE);

memset(pVoid, '*', BUF_SIZE);
char *szMsg = "Hello shared memory.";
CopyMemory(pVoi d, 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(h FileMap,
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 1095

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

Similar topics

4
7326
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 no use. This is working fine on win2k IE6 Here is the html file I am using to display the tif file <html> <head>
1
245
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 from file and in memory. currently I use copymemory extensively along with varptr. I want to continue to write fast code but I am not sure how efficient the serialize functions built into much of .net are. I also use filemapping to perform high speed...
3
1781
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 FileStream, br As BinaryReader Dim FilePath As String Dim data() As Byte
2
2181
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 operating system, the entire Netscape 7.2 browser and Firefox 1.0 browser shuts down when I try to use the Back button on these pages. Is there some setting in Windows XP that is causing this or is there something I can add to the Javascript to...
1
1270
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 application and database now only work in single user mode. The program starts ok and the menu is shown etc. But updating a record isn't possible they get an error like ".../.../xxx.mdb is invalid"
2
2131
by: Daniel Danilin | last post by:
Hi, is there any plans to make "WindowsXP Peer-To-Peer SDK" for .NET Framework?
1
1144
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 "Enable XP visual styles" checked in the Project's Application tab. Following code was placed in the frmMain_Load event, but still no XP themes. What else must be done? 'use WindowsXP themes
5
1047
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 (I see all the items as I should see after the installation according all manuals.) But when I tried to execute the *.asp files on my local disk with my IE, nothing hapens, t.i. even such code as below doesn't work at all: <%@ language...
1
1601
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 install it I get a popup with the following message: "Application popup: RegSvcs.exe - Common Language Runtime Debugging Services : Application has generated an exception that could not be handled.
1
1571
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
0
8065
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8524
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8394
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6052
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5507
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4013
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2527
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1379
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.