nblackburn Posted September 2, 2011 Share Posted September 2, 2011 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 More sharing options...
nblackburn Posted September 2, 2011 Author Share Posted September 2, 2011 (edited) 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 September 2, 2011 by nblackburn Link to comment Share on other sites More sharing options...
MvGulik Posted September 2, 2011 Share Posted September 2, 2011 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 More sharing options...
jaberwacky Posted September 2, 2011 Share Posted September 2, 2011 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. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 2, 2011 Share Posted September 2, 2011 You seem to have mixed up C# and C++. You've got some code from both in there. Link to comment Share on other sites More sharing options...
jaberwacky Posted September 3, 2011 Share Posted September 3, 2011 Hah, so it isn't even visualc++? I see I need to branch out and learn some more languages. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 3, 2011 Share Posted September 3, 2011 It is Visual C++, but it is the managed extensions (or whatever they are currently called). There's really no reason to use it. Straight VC++ or switching to C# would be tons easier. Link to comment Share on other sites More sharing options...
progrogrammer Posted September 10, 2011 Share Posted September 10, 2011 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 More sharing options...
progrogrammer Posted September 10, 2011 Share Posted September 10, 2011 #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 More sharing options...
Richard Robertson Posted September 11, 2011 Share Posted September 11, 2011 progrogrammer, what he is writing is managed C++, and what he is doing is fine. Also, you need to learn some C++. Multiple "using namespace" statements are fine. It just imports everything in those namespaces to the local root. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now