Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Declare Function CreatePen Lib "gdi32" Alias "CreatePen" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
dim hPen as long
hPen=CreatePen(必要参数)
DeleteObject hPen ‘释放掉pen的资源