| |

VerySource

 Forgot password?
 Register
Search
View: 788|Reply: 6

About OpenFileMapping

[Copy link]

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-2 19:10:01
| Show all posts |Read mode
HANDLE hMap = CreateFileMapping (INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE | SEC_COMMIT, 0,256, "S_DATA");
Ranch
}

void CTest4Dlg :: OnButton2 ()
{
HANDLE m_hMap = OpenFileMapping (FILE_MAP_READ, FALSE, "S_DATA");
Ranch
}
I wrote an example, but when I use OpenFileMapping to open the mapping address, hMap is not equal to m_hMap, so when I call MapViewOfFile to read the data in button2, an error occurs.
Excuse me, why are hMap and m_hMap not equal? ​​Where am I wrong? Thank you for your help.
Reply

Use magic Report

0

Threads

21

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 United States

Post time: 2020-1-2 19:12:01
| Show all posts
If your application is running in a termal server and you need access your file mapping from another user's account, add Global\\prefix to your object name, and modify the access control list when you create the object.
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-1-2 20:36:01
| Show all posts
I just want to store a structure in memory. Access by other processes. I am not mapping a file into memory. I don't quite understand what you mean. Can you be more specific and post the code?
Reply

Use magic Report

0

Threads

30

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-1-2 22:03:01
| Show all posts
Then create a shared segment.
Reply

Use magic Report

0

Threads

24

Posts

19.00

Credits

Newbie

Rank: 1

Credits
19.00

 China

Post time: 2020-1-2 22:36:01
| Show all posts
What is wrong?
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-1-6 13:45:01
| Show all posts
already solved. Thank you
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-9-4 16:45:02
| Show all posts
Host, how is sharing a structure realized, can you leave the source code or hint?
I read a structure into memory in process A, but process B did not get it.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list