Jump to content

[Solved] Shlwapi.dll, ColorRGBToHLS, Crash. ?


Recommended Posts

whatever Edited by MvGulik

"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

  • 2 months later...
Link to comment
Share on other sites

Taken over by Yashied!

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

whatever Edited by MvGulik

"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

whatever Edited by MvGulik

"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

Your call only uses "word" types, not "word*".

Look at the MSDN page where they use "word*" for output. I'm not sure "dword*" would be correct.

Also I believe the way you setup $iColorRef isn't 100% correct: converting this way from floating-point gives a 64-bit integer:

Local $iColorRef = _GetColorValue($anRGB, True) ;; RGB to BGR

_DebugReportVar('$iColorRef', $iColorRef) ;### Debug DebugOut.

_DebugReportVar('hex($iColorRef)', hex($iColorRef)) ;### Debug DebugOut.

ConsoleWrite(VarGetType($iColorRef) & @LF) ; <<-- Int64

Passing it to DllCall with type "word" amounts to a cast, but I'd personally prefer a more explicit way to do so for my own code, just to be safe.

Maybe that's a nitpick.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

I'm not sure "dword*" would be correct.

It's does not matter, it's a pointer to the value of WORD type, or to the low-order word of DWORD type. This is the same.

ConsoleWrite(VarGetType(DllStructGetData(DllStructCreate('word'), 1)) & @CR)

Anyway, uses "Int32".

Edited by Yashied
Link to comment
Share on other sites

Granted, that works on little-endian machines.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

whatever Edited by MvGulik

"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

AFAICS DllCall will cast the value to a word, as the type dictates. As I said, it was merely a nitpick, mostly due to the fact I frequently work with big-endian or bi-endian processors. Being repeatedly bitten between the legs by such mistakes in low-level code for 150K$ instruments makes you code more carefully at low-level (and wear titanium underwear).

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Why are you confusing people with VarGetType() function? Don't do that.

AutoIt works with variants and VarGetType will show you a type of variant holding the value that DllCall returned.

If DllCall() returns/requires word type then word is what you should be using. If it's pointer to word then it's word*. Nothing more to say there really.

Of course you can use dword*, or maybe uint64* or dword_ptr*, but why would you???

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

I agree with trancexx. There's no logical reason to use a datatype other than what is listed for an API call. It may work here because when the memory is allocated for a "dword*", you initialize it with 0. However, if you initialize it with something > 65535, things will fall apart.

Example:

$aResult = DllCall("shlwapi.dll", "none", "ColorRGBToHLS", "dword", $iColorRef, "dword*", 65536, "dword*", 65536, "dword*", 65536)
ConsoleWrite("Hue:"&$aResult[2]&", Lum:"&$aResult[3]&", Sat:"&$aResult[4]&@CRLF)

As you can see, the values returned are incorrect. The reason is the API call only writes a 16-bit value to the area pointed to. The upper 16-bits remain untouched.

You can change the above to "word*" and still keep 65536 there, and you'll actually get the correct return.

The point of all this is to use datatypes as they are defined. (especially with return and pointer types)

Link to comment
Share on other sites

whatever Edited by MvGulik

"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

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...