MartinMcD Posted October 24, 2011 Report Share Posted October 24, 2011 Hello there, I am trying and failing to set up a call to the kernall32 function GetFullPathName, I keep getting stuck on these things. Would anybody be able to help me please? I've attached what I have so far but the call just crashes LabVIEW straight away. Thank you very much as ever, Martin Quote Link to comment
Jon Kokott Posted October 24, 2011 Report Share Posted October 24, 2011 Need type definitions for DWORD, LPTRSTR, LPCTSTR. your return type is definitely not double. but convention would say that your function prototype should look like: int32_t GetLongPathName(const char* lpszshortpath, const char* lpszlongpath, int32_t ccBuffer) Check this out: http://www.codeproject.com/Tips/76252/What-are-TCHAR-WCHAR-LPSTR-LPWSTR-LPCTSTR-etc I think that lpszshortpath is expecting a Unicode string, so you may have to convert the actual string you put in from ANSI to Unicode. ~Jon Quote Link to comment
asbo Posted October 24, 2011 Report Share Posted October 24, 2011 Which one are you trying to use, GetFullPathName or GetLongPathName? Quote Link to comment
Darin Posted October 24, 2011 Report Share Posted October 24, 2011 Assuming you meant GetLongPath. TestShortPathLongPath.vi Quote Link to comment
ned Posted October 25, 2011 Report Share Posted October 25, 2011 Looks right, but one note: you don't need to allocate a second 260-element array, you can just fork the "ShortPath" wire. Quote Link to comment
asbo Posted October 25, 2011 Report Share Posted October 25, 2011 If you're worried about a tidy block diagram, you don't need either allocations - just wire in 260 to the buffer length terminals and configure the CLN to use that input as the Minimum Length for the output buffer. You'll over-allocate in most cases, but what's a few bytes among friends? Also, you don't need to run most of these utility APIs in the UI thread. Quote Link to comment
Darin Posted October 25, 2011 Report Share Posted October 25, 2011 As you tidy up the BD keep in mind that nobody would use these functions back to back since that is simply path to string. Basically I wanted a short path to verify the long path worked. As to the length, most of these functions will return the necessary length if you call with a null buffer (Length=0). Quote Link to comment
MartinMcD Posted October 25, 2011 Author Report Share Posted October 25, 2011 Hi all, Wowzers, thank you for all of that, perfect. Thank you very much! Martin Quote Link to comment
asbo Posted October 25, 2011 Report Share Posted October 25, 2011 As you tidy up the BD keep in mind that nobody would use these functions back to back since that is simply path to string. Basically I wanted a short path to verify the long path worked. As to the length, most of these functions will return the necessary length if you call with a null buffer (Length=0). Not sure if this was directed at me, but I'm aware One things to keep in mind if you're going to act on the return value is that if the buffer is too small, the function returns the *size of the buffer* you need for the string; if the buffer is big enough, it returns the *length of the string* (no null terminator). Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.