How can I calculate the complete buffer size for GetModuleFileName?

后端 未结 8 2049
花落未央
花落未央 2020-12-17 17:08

The GetModuleFileName() takes a buffer and size of buffer as input; however its return value can only tell us how many characters is has copied, and if the size is not enoug

8条回答
  •  粉色の甜心
    2020-12-17 18:01

    Implement some reasonable strategy for growing the buffer like start with MAX_PATH, then make each successive size 1,5 times (or 2 times for less iterations) bigger then the previous one. Iterate until the function succeeds.

提交回复
热议问题