[SOLVED] Using the SHCreateDirectoryExA function

Posted By: Aku_Aku

[SOLVED] Using the SHCreateDirectoryExA function - 08/12/20 13:33

Hi All!

I tried to use this function: SHCreateDirectoryExA
I can't call it to life. Here is how I tried to do:
Code
int WINAPI SHCreateDirectoryEx(HWND hwnd, LPCSTR pszPath, void* psa);
#define PRAGMA_API SHCreateDirectoryEx;Shell32.dll!SHCreateDirectoryExA
SHCreateDirectoryEx(NULL, _chr(pif), NULL);

I got a crash for the third line: "Script crash in main"

I included the following headers:
Code
#include <acknex.h>
#include <strio.c>
#include <windows.h>
#include <stdio.h>

What should be the correct way of the usage of this function?
Posted By: Emre

Re: Using the SHCreateDirectoryExA function - 08/12/20 21:46

Hi,it works here. I am not getting any errors.

Code
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <windows.h>
///////////////////////////////

int WINAPI SHCreateDirectoryEx(HWND hwnd, LPCSTR pszPath, void* psa);
#define PRAGMA_API SHCreateDirectoryEx;Shell32.dll!SHCreateDirectoryExA

STRING* pif="c:\\xx";
function main()
{
	SHCreateDirectoryEx(NULL, _chr(pif), NULL);

	//verification
	if(GetFileAttributes(_chr(pif))!=0xFFFFFFFF)
	{
		printf("Done!");
	}
}
Posted By: Aku_Aku

Re: Using the SHCreateDirectoryExA function - 08/13/20 14:32

Interesting... I going to try it again, maybe I did something wrong.
Thanks.

Edit:
OK, I've catched the reason. The function declaration was in the main at my side.
After I moved that out of the main, it suddenly began to work. Now it is OK.
Thanks again Emre.
Posted By: Dooley

Re: Using the SHCreateDirectoryExA function - 08/13/20 16:23

Brackets seem to help when I am programming. I know there are situations where you don't technically need them, but I tend to stay safe and use them all the time.
Posted By: Aku_Aku

Re: Using the SHCreateDirectoryExA function - 08/13/20 18:30

@Emre: Strange... Doesn't work for me... I have got the message: Script crashes in main.
I am investigating more on that.
It is OK now, as I explained in my edited previous post.
Posted By: Aku_Aku

Re: Using the SHCreateDirectoryExA function - 08/13/20 18:31

Which brackets did you mean?
© 2024 lite-C Forums