//main.cpp
int a=0; //全局初始化区
char *p1; //全局未初始化区
main()
{
intb;栈
char s[]="abc"; //栈
char *p2; //栈
char *p3="123456"; //123456\0在常量区,p3在栈上。
static int c=0; //全局(静态)初始化区
p1 = (char*)malloc(10);
p2 = (char*)malloc(20); //分配得来得10和20字节的区域就在堆区。
strcpy(p1,"123456"); //123456\0放在常量区,编译器可能会将它与p3所向"123456"优化成一个地方。
}
int a=0; //全局初始化区
char *p1; //全局未初始化区
main()
{
intb;栈
char s[]="abc"; //栈
char *p2; //栈
char *p3="123456"; //123456\0在常量区,p3在栈上。
static int c=0; //全局(静态)初始化区
p1 = (char*)malloc(10);
p2 = (char*)malloc(20); //分配得来得10和20字节的区域就在堆区。
strcpy(p1,"123456"); //123456\0放在常量区,编译器可能会将它与p3所向"123456"优化成一个地方。
}
char *s2="bbbbbbbbbbbbbbbbb"; //bbbbbbbbbbb是在编译时就确定的
#include
voidmain()
{
char a=1;
char c[]="1234567890";
char *p="1234567890";
a = c[1];
a = p[1];
return;
}10:a=c[1];
004010678A4DF1movcl,byteptr[ebp-0Fh]
0040106A884DFCmovbyteptr[ebp-4],cl
11:a=p[1];
0040106D8B55ECmovedx,dwordptr[ebp-14h]
004010708A4201moval,byteptr[edx+1]
004010738845FCmovbyteptr[ebp-4],al
iTemp[1000*256-1] = 99.0;
CString str;
str.Format("%d", iTemp[1000*256-1]);
AfxMessageBox(str);
unsigned char x;
unsigned char y;
int z;
}MyStruct;type MyStruct
x as byte
y as byte
z as long
End TypePrivate Type Strc
a as Byte
b as Integer
c as Long
d as Byte
End Type Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As Long, ByVal Source As Long, ByVal Length As Long)Private Type MyStruct
X As Byte
y As Byte
' m As Integer
z As Long
End Type
Private Sub Form_Load()
Dim X As MyStruct
Dim l As Long, m As Long
l = 8888888
X.X = 1
X.y = 2
X.z = 9999999
'以非对齐结构取z的值到l
m = VarPtr(X.X) + 2
CopyMemory ByVal VarPtr(l), ByVal m, 4
MsgBox l
'以对齐结构取z的值取l
m = VarPtr(X.X) + 4
CopyMemory ByVal VarPtr(l), ByVal m, 4
MsgBox l
End Subtypedef struct _tagA{
char x;
}A;
typedef struct _tagB{
A a;
char y;
}B;
typedef struct _tagC{
B b;
int z;
}C;
typedef struct _tagD{
C c;
char t;
}D;printf("sizeof(A)=%d,sizeof(B)=%d,sizeof(C)=%d,sizeof(D)=%d\r\n",sizeof(A),sizeof(B),sizeof(C),sizeof(D));Private Sub Command1_Click()
Dim t As Boolean, strTest$, bB As Byte, iLong&, iT%, iKK&
strTest = "123456"
Debug.Print Hex$(VarPtr(t))
Debug.Print Hex$(VarPtr(strTest)), Hex$(StrPtr(strTest))
Debug.Print Hex$(VarPtr(bB))
Debug.Print Hex$(VarPtr(iLong))
Debug.Print Hex$(VarPtr(iT))
Debug.Print Hex$(VarPtr(iKK))
strTest = strTest & "ABCD"
Debug.Print Hex$(VarPtr(strTest)), Hex$(StrPtr(strTest))
End Subtypedef struct _tagMyStruct{
unsigned char x;
unsigned char y;
short reserved;
int z;
}MyStruct;type MyStruct
x as byte
y as byte
reserved as integer
z as long
End Typeint a[888];
int *p = & a[0]; int a[2] = {99, 88};
int *p = a;
p++;Dim a(1) As Integer
a(0) = 99
a(1) = 88
Dim p As Long
p = VarPtr(a(0))
p = p + 2typedef struct _tagMyStruct{
unsigned char x;
unsigned char y;
short reserved;
int z;
}MyStruct,*LPMyStruct;LPMyStruct P;
P = 0;
P ++;//这里是P = (LPMyStruct)((unsigned long)P + sizeof(MyStruct)),而不是P = (LPMyStruct)((unsigned long)P + 1);
对,像FRJJ那种S................................
[/Quote]汗一个 - - 确实是粗狂的S...
请问myjian,你这个帖子里的第一个链接里的表情如何用呢?没看到拷贝地址在哪里啊?
vTAB
tPOS
vGET
sSND
vPHT
sTAB
sPHT
End EnumPrivate Type tPack
eCMD As eCommand 'long型, 4个字节
iID As Integer '高位对齐, 4字节
bFilepack() As Byte '4字节, 变长数组的注册地址
End TypePrivate Sub Command1_Click()
Dim number As Integer, i As Integer
Dim data1() As Byte
Dim data2() As Byte
Dim pack1 As tPack
pack1.eCMD = tPOS
pack1.iID = 1
ReDim pack1.bFilepack(0)
ReDim data2(0)
pack1.bFilepack(0) = 2
number = LenB(pack1) '12字节
ReDim data1(number - 5) '最后的指针不需要 CopyMemory data1(0), pack1, number - 4
CopyMemory data2(0), pack1.bFilepack(0), UBound(pack1.bFilepack) + 1
Debug.Print "data2(0): " & data2(0)
Debug.Print "eCMD: " & data1(0)
Debug.Print "iID: " & data1(4)
End Sub
我的方法是:
在图片上点鼠标右键,在弹出的菜单中点“属性”(弹出菜单最下面那一项就是“属性”)。
然后就弹出一个窗口,它的中间就有图片的URL,把它复制下来就行了。够简单吧!
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)Option ExplicitPrivate Type MyStruct
x As Byte
y As Byte
z As Long
End TypePrivate Sub Form_Load()
Dim t As MyStruct
With t
.x = 12
.y = 34
.z = &H5678 '在内存中存放为 &H78 &H56 &H00 &H00
End With
Dim p As Long
Dim b As Byte
p = VarPtr(t)
Call CopyMemory(b, ByVal p + 2, 1)
Debug.Print Hex(b)
Call CopyMemory(b, ByVal p + 4, 1)
Debug.Print Hex(b)
End Sub
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongPrivate Function GetHTreeItem(ByVal nodX As MSComctlLib.Node, treX As MSComctlLib.TreeView) As Long
nodX.Selected = True
GetHTreeItem = SendMessage(treX.hwnd, TVM_GETNEXTITEM, TVGN_CARET, 0)
End Function'for treeview
Public Const TV_FIRST As Long = &H1100
Public Const TVM_GETNEXTITEM As Long = TV_FIRST + 10
Public Const TVM_GETITEM = TV_FIRST + 12
Public Const TVM_EXPAND As Long = TV_FIRST + 2
Public Const TVE_EXPAND As Long = &H2
Public Const TVM_GETITEMRECT = TV_FIRST + 4
' the specified Node, returns 0 otherwise.
Public Function GetTVItemFromNode(hwndTV As Long, nod As Node) As Long
Dim nod1 As MSComctlLib.Node
Dim anSiblingPos() As Integer ' contains the sibling position of the node and all it's parents
Dim nLevel As Integer ' hierarchical level of the node
Dim hItem As Long
Dim i As Integer
Dim nPos As Integer
Set nod1 = nod
' Continually work backwards from the current node to the current node's
' first sibling, caching the current node's sibling position in the one-based
' array. Then get the first sibling's parent node and start over. Keep going
' until the postion of the specified node's top level parent item is obtained...
Do While (nod1 Is Nothing) = False
nLevel = nLevel + 1
ReDim Preserve anSiblingPos(nLevel)
anSiblingPos(nLevel) = GetNodeSiblingPos(nod1)
Set nod1 = nod1.Parent
Loop
' Get the hItem of the first item in the treeview
hItem = TreeView_GetRoot(hwndTV)
If hItem Then
' Now work backwards through the cached node positions in the array
' (from the first treeview node to the specified node), obtaining the respective
' item handle for each node at the cached position. When we get to the
' specified node's position (the value of the first element in the array), we
' got it's hItem...
For i = nLevel To 1 Step -1
nPos = anSiblingPos(i)
Do While nPos > 1
hItem = TreeView_GetNextSibling(hwndTV, hItem)
nPos = nPos - 1
Loop
If (i > 1) Then hItem = TreeView_GetChild(hwndTV, hItem)
Next
GetTVItemFromNode = hItem
End If ' hItem
End Function' Retrieves the first child item. The hitem parameter must be NULL.
' Returns the handle to the item if successful or 0 otherwise.
Private Function TreeView_GetChild(hWnd As Long, hItem As Long) As Long
TreeView_GetChild = TreeView_GetNextItem(hWnd, hItem, TVGN_CHILD)
End Function' Retrieves the tree-view item that bears the specified relationship to a specified item.
' Returns the handle to the item if successful or 0 otherwise.
Private Function TreeView_GetNextItem(hWnd As Long, hItem As Long, flag As Long) As Long
TreeView_GetNextItem = SendMessage(hWnd, TVM_GETNEXTITEM, ByVal flag, ByVal hItem)
End Function' Retrieves the next sibling item.
' Returns the handle to the item if successful or 0 otherwise.
Private Function TreeView_GetNextSibling(hWnd As Long, hItem As Long) As Long
TreeView_GetNextSibling = TreeView_GetNextItem(hWnd, hItem, TVGN_NEXT)
End Function' Retrieves the topmost or very first item of the tree-view control.
' Returns the handle to the item if successful or 0 otherwise.
Private Function TreeView_GetRoot(hWnd As Long) As Long
TreeView_GetRoot = TreeView_GetNextItem(hWnd, 0, TVGN_ROOT)
End Function' Returns the one-base position of the specified node
' with respect to it's sibling order.
Private Function GetNodeSiblingPos(nod As Node) As Integer
Dim nod1 As Node
Dim nPos As Integer
Set nod1 = nod
' Keep counting up from one until the node has no more previous siblings
Do While (nod1 Is Nothing) = False
nPos = nPos + 1
Set nod1 = nod1.Previous
Loop
GetNodeSiblingPos = nPos
End Function
[ftc=#006699]dim[/ft] [ftc=#000000]x1[/ft] [ftc=#000000]as[/ft] [ftc=#000000]class1[/ft]
[ftc=#006699]dim[/ft] [ftc=#000000]x2[/ft] [ftc=#000000]as[/ft] [ftc=#000000]class2[/ft][ftc=#006699]set[/ft] [ftc=#000000]x2[/ft] [ftc=#555555]=[/ft] [ftc=#006699]new[/ft] [ftc=#000000]class2[/ft]
[ftc=#006699]set[/ft] [ftc=#000000]x1[/ft] [ftc=#555555]=[/ft] [ftc=#000000]x2[/ft][ftc=#000000].[/ft][ftc=#000000]xxx[/ft] [ftc=#006699]stop[/ft] [ftc=#0099ff]'在这里看看x1是不是nothing[/ft][ftc=#006699]for[/ft] [ftc=#000000]i[/ft][ftc=#555555]=[/ft][ftc=#ff6600]1[/ft] [ftc=#006699]to[/ft] [ftc=#000000]x1[/ft][ftc=#000000].[/ft][ftc=#000000]count[/ft]
[ftc=#006699]next[/ft] [ftc=#000000]i[/ft]
[/ft]
dim x1 as class1
dim x2 as class2set x2 = new class2
set x1 = x2.xxx stop '在这里看看x1是不是nothingfor i=1 to x1.count
next i
[/FONT]
dim x1 as class1
dim x2 as class2set x2 = new class2
set x1 = x2.xxx stop '在这里看看x1是不是nothingfor i=1 to x1.count
next i
dim x1 as class1
dim x2 as class2set x2 = new class2
set x1 = x2.xxx stop '在这里看看x1是不是nothingfor i=1 to x1.count
next i
[/FONT]
dim x1 as class1
dim x2 as class2set x2 = new class2
set x1 = x2.xxx stop '在这里看看x1是不是nothingfor i=1 to x1.count
next i
:你觉得这可能么?
:呵呵,呃(打嗝ing)
:兄台说得太精P了
:来块吧
:不在沉默中死亡,就在沉默中爆发
:来啊 你
:俺要飞
:恶魔
:丫找CEI呢吧
:(挤眉弄眼的)恩,就是,就是
:打篮球去
:又踢皮球
:看看这是几(一种测试白痴的方法)
:去,别捣乱,俺跳绳呢
:啊 我我我 有点笨来着
:TNND
:BS你
:打乒乓
:瓢虫
:看看这是几(另一种测试白痴的方法)
:拍蚊子
:Orz,为什么这样对我啊
:恩?这是为什么?
:从右侧BS你
:咖啡or红茶
:很香的一坨……
:活动手腕及食指
:荷支扫把在肩上,牧童的的歌声在荡漾
看这里:http://topic.csdn.net/u/20090623/15/83fd893b-1ca1-42aa-932f-d7abb284a55e.html