 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
majkinetor
Joined: 24 May 2006 Posts: 3544 Location: Belgrade
|
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 808 Location: Germany
|
Posted: Tue Apr 17, 2007 2:01 pm Post subject: |
|
|
Ahh ... very great. Thanks for that. _________________ Tekl |
|
| Back to top |
|
 |
raven-gm
Joined: 25 Mar 2007 Posts: 24
|
Posted: Tue Apr 17, 2007 5:07 pm Post subject: |
|
|
So wait...
We'd just need to find someone who knows COM well enough to show us how to use it for file get/set properties in ahk? |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Tue Apr 17, 2007 6:28 pm Post subject: |
|
|
| Quote: | | We'd just need to find someone who knows COM well enough to show us how to use it for file get/set properties in ahk´? | So you're now out for hunting? Good luck  |
|
| Back to top |
|
 |
raven-gm
Joined: 25 Mar 2007 Posts: 24
|
Posted: Wed Apr 18, 2007 4:28 am Post subject: |
|
|
| BoBo wrote: | | Quote: | | We'd just need to find someone who knows COM well enough to show us how to use it for file get/set properties in ahk´? | So you're now out for hunting? Good luck  |
K, to be more specific...
From what I've seen/heard, ahk runs off of c++.
So I should find someone who can do COM in c++, or find a way to recieve and/or edit metadata in c++ at all? _________________ I would like to think that I know what I'm doing, but there's just to much stuff I've yet to learn... |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1141
|
Posted: Wed Apr 18, 2007 9:20 am Post subject: |
|
|
Although I have a little experience with a securable object, I have currently little time to delve further into this big subject. So, I just wrote a script to convert between name and SID. So, you may use it with cacls.exe until AHK natively supports the functions.
| Code: | MsgBox % sName := LookupAccountSid("S-1-1-0")
MsgBox % sSid := LookupAccountName(sName)
LookupAccountName(sName, sSystem = "")
{
DllCall("advapi32\LookupAccountNameA", "str", sSystem, "str", sName, "Uint", 0, "UintP", nSizeSID, "Uint", 0, "UintP", nSizeRDN, "UintP", eUser)
VarSetCapacity(SID, nSizeSID, 0)
VarSetCapacity(RDN, nSizeRDN, 0)
DllCall("advapi32\LookupAccountNameA", "str", sSystem, "str", sName, "str", SID, "UintP", nSizeSID, "str", RDN, "UintP", nSizeRDN, "UintP", eUser)
DllCall("advapi32\ConvertSidToStringSidA", "str", SID, "UintP", pString)
VarSetCapacity(sSid, DllCall("lstrlen", "Uint", pString))
DllCall("lstrcpy", "str", sSid, "Uint", pString)
DllCall("LocalFree", "Uint", pString)
Return sSid
}
LookupAccountSid(sSid, sSystem = "")
{
DllCall("advapi32\ConvertStringSidToSidA", "str", sSid, "UintP", pSid)
DllCall("advapi32\LookupAccountSidA", "str", sSystem, "Uint", pSid, "Uint", 0, "UintP", nSizeNM, "Uint", 0, "UintP", nSizeRD, "UintP", eUser)
VarSetCapacity(sName, nSizeNM, 0)
VarSetCapacity(sRDmn, nSizeRD, 0)
DllCall("advapi32\LookupAccountSidA", "str", sSystem, "Uint", pSid, "str", sName, "UintP", nSizeNM, "str", sRDmn, "UintP", nSizeRD, "UintP", eUser)
DllCall("LocalFree", "Uint", pSid)
Return sName
}
|
BTW, if the name contains accented characters, you may also need to convert it to OEM codepage using Ansi2Oem() in
http://www.autohotkey.com/forum/topic17343.html |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3842 Location: Bremen, Germany
|
Posted: Wed Apr 18, 2007 11:10 am Post subject: |
|
|
Thanks Sean,
these are exactly the functions I was looking for for a different project. Thanks for sharing. Since these are very basic and useful functions I suggest to post them in the functions section of this forum too. _________________ Ciao
toralf  |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1141
|
Posted: Wed Apr 18, 2007 11:33 am Post subject: |
|
|
| toralf wrote: | Thanks Sean,
these are exactly the functions I was looking for for a different project. Thanks for sharing. Since these are very basic and useful functions I suggest to post them in the functions section of this forum too. |
Thanks. I've done it. |
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 808 Location: Germany
|
Posted: Fri Apr 20, 2007 6:10 am Post subject: |
|
|
Where have I to user Ansi2Oem? LookupAccountSid or LookupAccountName? _________________ Tekl |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1141
|
Posted: Fri Apr 20, 2007 8:55 am Post subject: |
|
|
| Tekl wrote: | | Where have I to user Ansi2Oem? LookupAccountSid or LookupAccountName? |
Like this:
| Code: | | sName := Ansi2Oem(LookupAccountSid("S-1-1-0")) |
Then, use sName with cacls.exe. |
|
| Back to top |
|
 |
raven-gm(but not logged i Guest
|
Posted: Sun May 13, 2007 4:43 am Post subject: |
|
|
Alright, went through and read it.
I don't know enough c++ (Or any COM), but the example provided
http://msdn2.microsoft.com/en-us/library/aa380387.aspx
looks comprehendable.
Anyone who knows what they're talking about want to take a look? |
|
| Back to top |
|
 |
raven-gm
Joined: 25 Mar 2007 Posts: 24
|
Posted: Sun May 13, 2007 5:00 pm Post subject: |
|
|
(oops, I suppose I should say that "it" is the link that majkinetor provided:
http://msdn2.microsoft.com/en-us/library/aa379968.aspx )
And the example code looks like this:
| Code: | //+===================================================================
//
// To build:
// cl /GX WriteRead.cpp
//
//+===================================================================
#define WIN32_LEAN_AND_MEAN
#define UNICODE
#define _UNICODE
#include <stdio.h>
#include <windows.h>
#include <ole2.h>
// Implicitly link ole32.dll
#pragma comment( lib, "ole32.lib" )
// From uuidgen.exe:
const FMTID fmtid = { /* d170df2e-1117-11d2-aa01-00805ffe11b8 */
0xd170df2e,
0x1117,
0x11d2,
{0xaa, 0x01, 0x00, 0x80, 0x5f, 0xfe, 0x11, 0xb8}
};
EXTERN_C void wmain()
{
HRESULT hr = S_OK;
IPropertySetStorage *pPropSetStg = NULL;
IPropertyStorage *pPropStg = NULL;
WCHAR *pwszError = L"";
PROPSPEC propspec;
PROPVARIANT propvarWrite;
PROPVARIANT propvarRead;
try
{
// Create a file and a property set within it.
hr = StgCreateStorageEx( L"WriteRead.stg",
STGM_CREATE|STGM_SHARE_EXCLUSIVE|STGM_READWRITE,
STGFMT_STORAGE,
// STGFMT_STORAGE => Structured Storage
// property sets
// STGFMT_FILE => NTFS file system
// property sets
0, NULL, NULL,
IID_IPropertySetStorage,
reinterpret_cast<void**>(&pPropSetStg) );
if( FAILED(hr) ) throw L"Failed StgCreateStorageEx";
hr = pPropSetStg->Create( fmtid, NULL, PROPSETFLAG_DEFAULT,
STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE,
&pPropStg );
if( FAILED(hr) ) throw L"Failed IPropertySetStorage::Create";
// Write a Unicode string property to the property set
propspec.ulKind = PRSPEC_LPWSTR;
propspec.lpwstr = L"Property Name";
propvarWrite.vt = VT_LPWSTR;
propvarWrite.pwszVal = L"Property Value";
hr = pPropStg->WriteMultiple( 1, &propspec, &propvarWrite,
PID_FIRST_USABLE );
if( FAILED(hr) )
throw L"Failed IPropertyStorage::WriteMultiple";
// Not required, but give the property set a friendly
// name.
PROPID propidDictionary = PID_DICTIONARY;
WCHAR *pwszFriendlyName =
L"Write/Read Properties Sample Property Set";
hr = pPropStg->WritePropertyNames( 1, &propidDictionary,
&pwszFriendlyName );
if( FAILED(hr) )
throw L"Failed IPropertyStorage::WritePropertyNames";
// Close and reopen everything.
// By using the STGFMT_ANY flag in the StgOpenStorageEx call,
// it does not matter if this is a Structured Storage
// property set or an NTFS file system property set
// (for more information see the StgCreateStorageEx
// call above).
pPropStg->Release(); pPropStg = NULL;
pPropSetStg->Release(); pPropSetStg = NULL;
hr = StgOpenStorageEx( L"WriteRead.stg",
STGM_READ|STGM_SHARE_DENY_WRITE,
STGFMT_ANY,
0, NULL, NULL,
IID_IPropertySetStorage,
reinterpret_cast<void**>(&pPropSetStg) );
if( FAILED(hr) )
throw L"Failed StgOpenStorageEx";
hr = pPropSetStg->Open( fmtid, STGM_READ|STGM_SHARE_EXCLUSIVE,
&pPropStg );
if( FAILED(hr) )
throw L"Failed IPropertySetStorage::Open";
// Read the property back and validate it
hr = pPropStg->ReadMultiple( 1, &propspec, &propvarRead );
if( FAILED(hr) )
throw L"Failed IPropertyStorage::ReadMultiple";
if( S_FALSE == hr )
throw L"Property didn't exist after reopening the
property set";
else if( propvarWrite.vt != propvarRead.vt )
throw L"Property types didn't match after reopening the
property set";
else if( 0 != wcscmp( propvarWrite.pwszVal,
propvarRead.pwszVal ))
throw L"Property values didn't match after reopening the
property set";
else
wprintf( L"Success\n" );
}
catch( const WCHAR *pwszError )
{
wprintf( L"Error: %s (hr=%08x)\n", pwszError, hr );
}
PropVariantClear( &propvarRead );
if( pPropStg ) pPropStg->Release();
if( pPropSetStg ) pPropSetStg->Release();
} |
But I don't know how to test it; I don't have a C++ compiler anymore, or the ole32.dll it needs. _________________ I would like to think that I know what I'm doing, but there's just to much stuff I've yet to learn... |
|
| Back to top |
|
 |
dicanus
Joined: 04 Sep 2007 Posts: 2
|
Posted: Tue Apr 22, 2008 8:45 pm Post subject: |
|
|
| It's been almost a year, and I was just wondering if any new leaps have been made on this function. |
|
| Back to top |
|
 |
raven-gm
Joined: 25 Mar 2007 Posts: 24
|
Posted: Wed Apr 23, 2008 3:52 am Post subject: |
|
|
nope! But I switched to reading the IDTB file by hand anyways...
My advice is to switch languages. I had to. Autohotkey is dieing/dead, as sad as it seems, and it might help to have something a little more powerful (such as python) under your belt.
Of course, I still know ahk better, and I really miss it... but it has its limitations. _________________ I would like to think that I know what I'm doing, but there's just to much stuff I've yet to learn... |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|