thanks, nice to be back ;p
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
unsigned int GetIcon(unsigned long client, unsigned long flags) {
unsigned int rettemp = 0;
switch (client) {
case CLIENT_CHAT: //0x43484154:
rettemp++;
case CLIENT_W3XP: //0x57335850:
rettemp++;
case CLIENT_WAR3: //0x57415233:
rettemp++;
case CLIENT_W2BN: //0x5732424E:
rettemp++;
case CLIENT_D2XP: //0x44325850:
rettemp++;
case CLIENT_D2DV: //0x44324456:
rettemp++;
case CLIENT_DSHR: //0x44534852:
rettemp++;
case CLIENT_DRTL: //0x4452544C:
rettemp++;
case CLIENT_JSTR: //0x4A535452:
rettemp++;
case CLIENT_SSHR: //0x53534852:
rettemp++;
case CLIENT_SEXP: //0x53455850:
rettemp++;
}
if ((flags & 1) == 1)
rettemp = 12;
if ((flags & 2) == 2)
rettemp = 13;
if ((flags & 4) == 4)
rettemp = 14;
if ((flags & 8) == 8)
rettemp = 15;
if ((flags & 32) == 32)
rettemp = 16;
if ((flags & 64) == 64)
rettemp = 17;
return rettemp;
}
unsigned int GetIcon(unsigned long flags) {
unsigned int rettemp = 1;
if ((flags & 1) == 1)
rettemp = 12;
if ((flags & 2) == 2)
rettemp = 13;
if ((flags & 4) == 4)
rettemp = 14;
if ((flags & 8) == 8)
rettemp = 15;
if ((flags & 32) == 32)
rettemp = 16;
if ((flags & 64) == 64)
rettemp = 17;
return rettemp;
}
Quote
not sure if hard parts is the right phrase - more like the large parts.
Quote from: Joex86] link=topic=16610.msg168254#msg168254 date=1177265059]
They are not BSTRs. I tested that code and it's output is exactly as intended.
Also, this was only meant as a demonstration. Correct calling to the base of the byte array would be byteArray(LBound(byteArray)).
For defining the length of the string, I didn't really have to do that either. I could have done Len(str).
Using Step 1 is a good coding habit -- it prepares you for stepping up to C++, and makes it easier for your code to be understood by non-VB users. I'll reiterate the demonstration only clause for the repeated MsgBox calls.
Lastly, VB6 is not smart at all, let alone smart enough to position the bytes correctly. That is done by the Win32 API, but doesn't take any smartness on it's behalf. The lowbound of the byte array points to the first byte in memory. A byte array is stored in memory as a pointer to a bunch of bytes, that pointer pointing to the first one. RtlMoveMemory works somewhat like this:
; void RtlMoveMemory(void dest, void src, int length)
; {
xor esi, esi
_start:
cmp esi, length
je _bottom
inc esi
lea [dest+esi], [src+esi]
jmp _start:
_bottom:
: }
EDIT -
If you want a pointer to the string, pass an Integer ByVal in dest. Make sure you specifiy ByVal, though, because if it's passed ByRef it will be returned with the value 0x33323130 (little endian) and the 6 bytes following it will be murdified. Well.. the bytes after it will get owned anyhow, which is why the API is dangerous if you don't know what you're doing.
Quote
I want to make an array version of this, anyone have any ideas? I think I would just need to change VarPtr to VarPtrArray or something like that....... I saw "VarPtrArray" somewhere on msdn. And for the record, if anyone says the AddressOf operator and VarPtr() do the same thing, you're totally wrong! At least 3 people already said they're the same today and it's starting to piss me off -_____-;; Uh... so could anyone help?
Quote
Many thanks to Ante, he made this function while i was taking a poo. Anyways I'm still faced with the problem of finding the string len, any ideas on how to do this? :}
Quote
Private Function PtrString(ptrPointerType As PointerType) As String
Dim tmp$, i&
tmp = String(ptrPointerType.lngLen, vbNullChar)
CopyMemoryRead tmp, ptrPointerType.lngPtr, ptrPointerType.lngLen
For i= 1 To (ptrPointerType.lngLen * 2) - 1 Step 2
PtrString = PtrString & Mid$(tmp, i, 1)
Next i
End Function
Page created in 0.290 seconds with 16 queries.