| |

VerySource

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

Question about exe calling dll

[Copy link]

2

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-2-1 09:20:02
| Show all posts |Read mode
A string is output in the dll, and the string is obtained in the exe.
 dll:
   extern "C" _declspec (dllexport) int __stdcall CselectPathShel :: Path (CHAR * path)
{
   .......
}

exe:
 CHAR m_path [260];
 m_path [0] = 0;

 Path (m_path);

The programs in the dll are running normally, but the parameters m_path obtained in the exe are all garbled. After m_path [20] is the string that should be obtained from the dll. What is the problem and how can I change it? ?
Reply

Use magic Report

0

Threads

55

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-3-17 12:45:02
| Show all posts
Debug to see what the first 20 characters of the string are in the DLL.
Reply

Use magic Report

2

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-3-17 22:15:01
| Show all posts
Path "abc" in the dll and m_path "abc" in the exe
Reply

Use magic Report

0

Threads

55

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-3-18 11:30:01
| Show all posts
Then in the EXE, the string is assigned a null value.
Reply

Use magic Report

2

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-3-19 11:30:01
| Show all posts
Every time you run to Path (m_path), there is an interrupted dialog box that pops up, Run-Time Check Failure # 0-The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
Reply

Use magic Report

2

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-3-22 14:15:01
| Show all posts
I have solved it, my function should be defined in global
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-18 21:00:01
| Show all posts
Empty string
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