Jump to content
Sign in to follow this  
ghetek

Need help with Dllcall of kernel32

Recommended Posts

ghetek

I am trying to create a simple code to create a symbolic link. I would like to utilize the Microsoft function within their kernel32.dll library. from what i understand there are only 3 parameters necessary, Symlink, Target, and the "dwflags". It looks like the dwflag is just a 0 or 1 that denotes a file or a directory (respectively) for the linking.

Here is my code snippet so far:

Func CreatePortalDLL($Entrance, $Exit)
    $result = DllCall("kernel32.dll", "int", "CreateSymbolicLink", "str", $Entrance, "str", $Exit, "int", 1)
    ConsoleWrite($result & @CRLF)
EndFunc   ;==>CreatePortalDLL

Here is an example from microsoft in C#:

[DllImport("kernel32.dll", EntryPoint="CreateSymbolicLinkW", CharSet=CharSet.Unicode)]
public static extern int CreateSymbolicLink([In] string lpSymlinkFileName, [In] string lpTargetFileName, int dwFlags);

Everytime that I run this I just get back a 0 as a result and there is no symbolic link created. Any ideas? Thanks in advance AutoIT community! :blink:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×