Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / Accessing DBP temp folder

Author
Message
Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 2nd Nov 2006 20:36
Hi, is it possible from within a dll to figure out where the temp folder is, so I can extract temporary media to it and suchlike

WE SHALL BECOME ALL POWERFUL! CRUSH THE LESSER RACES! CONQUER THE GALAXY! UNIMAGINABLE POWER! UNLIMITED RICE PUDDING ! ! ! ETC. ! ! ! ETC.! ! !
CattleRustler
Retired Moderator
20
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 2nd Nov 2006 21:20
i remember doing this

spooky
21
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 2nd Nov 2006 21:22
How about this;



Boo!
Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 2nd Nov 2006 21:26
Well I wanted to do it within a dll plugin. Any idea how I would go about it there (Forgive me, but some parts of c++ are greek to me

WE SHALL BECOME ALL POWERFUL! CRUSH THE LESSER RACES! CONQUER THE GALAXY! UNIMAGINABLE POWER! UNLIMITED RICE PUDDING ! ! ! ETC. ! ! ! ETC.! ! !
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Nov 2006 21:41 Edited at: 2nd Nov 2006 21:42
It's pretty much the same idea - you call GetTempPath while providing it with a char array to put the results into, and the length of the buffer.

@Spooky,
Rather than use memblocks, why not simply create a string that's long enough for the result and then pass that? Saves having to do the conversion from memblock chars to a string.



Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 2nd Nov 2006 21:59
Thanks guys I managed to do it by calling the GetTempPath function, but from within my dll.

WE SHALL BECOME ALL POWERFUL! CRUSH THE LESSER RACES! CONQUER THE GALAXY! UNIMAGINABLE POWER! UNLIMITED RICE PUDDING ! ! ! ETC. ! ! ! ETC.! ! !
spooky
21
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 2nd Nov 2006 22:48
@IanM - thanks for the info. I'm still learning all this dll stuff and so my way is usually very long winded.

I did not realise you could pass a variable to dlls and it will automatically use it like a pointer, makes code much easier to understand. Just have to remember that strings need that extra nul character.

Also did not realise you could just pass 0,0 instead of bufferlength and buffer to get length without actually filling up a buffer. Naturally the MSDN help file neglects to tell you that.

It is true that "you learn something new every day"

Boo!
Mnemonix
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 2nd Nov 2006 23:34 Edited at: 2nd Nov 2006 23:41
I coded a 512 byte buffer in to my function, and if this is not long enough it takes as much memory as it needs to hold the path, although I can't forsee it taking up more than half a kilobyte

As a side query, is it possible to load a piece of media, e.g. "pic1.bmp" from the temp folder simply by doing load image("pic1.bmp"),1

I assume it is because of the way you can package media with your .exe file and load it up in this way

WE SHALL BECOME ALL POWERFUL! CRUSH THE LESSER RACES! CONQUER THE GALAXY! UNIMAGINABLE POWER! UNLIMITED RICE PUDDING ! ! ! ETC. ! ! ! ETC.! ! !
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 2nd Nov 2006 23:42
@Mnemonix,
Take a look at the alternative I've coded - it doesn't use a fixed buffer size, but gets windows to tell it how much is needed, and then reserves that amount.

@Spooky,
It's just one of the many things that MSDN doesn't tell you Most windows API functions where a size is passed back will work in the same way.

Also, don't get carried away with passing variables to API functions - only strings are passed to them in this way, as strings are simply pointers to the string data - it's the pointer that gets sent. Also, you don't really need to worry too much about the nul character as the string functions already include it, and neglecting to tell the API call that it has that extra 1 doesn't cause any harm.

Login to post a reply

Server time is: 2024-06-23 03:57:23
Your offset time is: 2024-06-23 03:57:23