Jump to content

Translating this autoit script into c++


nblackburn
 Share

Recommended Posts

Hello,

this is my very first post, i have found this awesome script on your forum and was wondering if you lovely people would help me translate it into c++ so i can use it with one of my projects.

$sUserName = "username"
$sPicPath = "usertile.png"
; call CoInitialize
DLLCall("ole32.dll","int","CoInitialize","ptr",0)
$hPicPath = DLLStructCreate("wchar[128]")
DllStructSetData($hPicPath, 1, $sPicPath)
$hUserName = DLLStructCreate("wchar[128]")
DllStructSetData($hUserName, 1, $sUserName)
$aRet = DllCall(@SystemDir & "\shell32.dll", "long", 262, "ptr", DllStructGetPtr($hUserName), "int", 0, "ptr", DllStructGetPtr($hPicPath))
MsgBox(4096, "SetUserTile", $aRet[0])

Thanks to anyone that helps, it means alot

Kind Regards,

Nathaniel Blackburn

Link to comment
Share on other sites

i have made an attempt at this to show im not lazy, but this currently doesnt work, it would mean the world to me if someone could help me finish this code asap, thanks again.

#using <mscorlib.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
 
#define DLL_EXPORT extern "C" __declspec(dllexport)
 
DLL_EXPORT long* SetUserTile(char* username char* imagepath) {
  
    CoInitialize();
  
    [DllImport("shell32.dll", EntryPoint = "#262", CharSet = CharSet.Unicode, PreserveSig = false)]
    public static extern void SetUserTile(string username, int whatever, string picpath);
    SetUserTile(username, 0, imagepath);
  
    CoUninitialize();
}

Best Wishes,

Nathaniel Blackburn

Edited by nblackburn
Link to comment
Share on other sites

Erm ... Think you got things mixed up a bit. This section is for AutoIt Help and not C(With or without additional plus tags.)

Suggest you ask your topic to be moved (ASAP -> use report button). to 'Chat' ... or 'Dev' forum, latter probably more fun for others forum users.

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

I've looked into and I've determined that my visual c++ skills are sorely lacking. However, I'll bet that if you include some error messages then someone might come along and help you out.

Link to comment
Share on other sites

I don't think this is C++ a 100%. For example wtf does [] do? Never saw it in any language. Also "public static extern void SetUserTile(string username, int whatever, string picpath);"

In C++ you don't need the "public static extern" part, you just declare a function like RetType name(blablabla);

So what exactly error messages do you get? I am to lazy to paste this into the compiler myself xD

Link to comment
Share on other sites

#using <mscorlib.dll>

in C++ you have to type #include <stuff> but I am not sure for Managed C++

using namespace System;

using namespace System::Runtime::InteropServices;

The second using cancels the first one so decide, using system or using system:runtime:interopstuffff

The only way I see this is an attempt to write a C++ code, ise because of the #define

And take out public in your function declaration, and you also have to define the function somewhere

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...