| |

VerySource

 Forgot password?
 Register
Search
View: 1136|Reply: 10

Problems passing data between dll and exe

[Copy link]

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-6 19:00:01
| Show all posts |Read mode
Should be the problem of passing data within the process?
I use a custom message in the dll
int cTxtLen = GetWindowTextLength (p-> hwnd);
Ranch
char * szWndName = new char [cTxtLen + 1];
Ranch
GetWindowText (p-> hwnd, szWndName, cTxtLen + 1);

SendMessage (g_hWnd, WM_DISPLAY_MSG, (WPARAM) szWndName, 0);

delete [] szWndName;

How to write the exe receiver?
I always write wrong.
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-5-29 10:30:01
| Show all posts
Deleted by you.
New out in your exe, and then give the pointer and the length to the dll, dll judges the length, and writes in the content as appropriate.
exe received its delete after running out.

Or you can write like this, but don't delete here dll, dll provides a function, the parameter is a pointer, special delete.

In addition, you can delete in the exe, this is not recommended.
Reply

Use magic Report

0

Threads

36

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-6-1 15:15:01
| Show all posts
Use files or use the registry for data transfer!
I do it all, it's not bad.
Reply

Use magic Report

0

Threads

10

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-6-9 20:15:02
| Show all posts
I think the first floor is wrong. . .
Sendmessage will not return until the exe is processed. If the WM_DISPLAY_MSG message is processed correctly in your exe, the following delete will work, so it will not be affected at all.
Just add a message response function in the main window of exe.

ON_MESSAGE(WM_DISPLAY_MSG, onDisplay)
........

You posted what you wrote, it should be something you wrote
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-6-10 12:30:02
| Show all posts
Intercept the WM_DISPLAY_MSG message in the callback function of the g_hWnd window in the exe (do not make a mistake in the window).

In addition, the definition of WM_DISPLAY_MSG should not be duplicated with the system or existing. Use WM_USER+XXXX
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-6-21 00:15:01
| Show all posts
That's all right, I was taught the response message function like this:
BOOL CSurveillantView::onDisplay (WPARAM wparam, LPARAM lparam)
{
   AfxMessageBox (char*(wparam));
}
Please advise!
Reply

Use magic Report

0

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-6-21 21:45:01
| Show all posts
You directly comment out delete to see what the result is.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-6-26 19:15:01
| Show all posts
Passing data between processes
Shared memory pipeline...
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-6-30 20:00:02
| Show all posts
Comment out delete, windows prompts an error after running, and then terminate the program -_-!
I also encountered this error
The correction should be AfxMessageBox ((char*) wparam);
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-6-30 21:15:01
| Show all posts
Back to the 7th floor: I said that this should be in-process communication, right?
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