Pages - Menu

2013/01/13

VB.Net DLL Call Memo

● -- ● VB.Net DLL Call Memo
.■■■ 資料型別摘要 (Visual Basic)
.■■■ VB.NET中指針和非託管內存的應用 ( IntPtr, Marshal 及 GCHandleMarshaling Structures
.■■■ 一見鍾情VB.NET指針
.■■■ VB.NET 一些陣列轉換
.■■■ 基礎程式設計(3)-基本資料型態 (一個呆子的網站)
.■■■ HOW TO:使用屬性建立 C/C++ 等位 (C# 和 Visual Basic)
.■■■ 從C#程序中調用非受管DLLs,關於屬性 , [StructLayout(LayoutKind.Sequential)] - .NET技術 / C#
.■■■ System.Runtime.InteropServices.StructLayout 允許的值有StructLayout.Auto StructLayout.Sequential StructLayout.Explicit ;  StructLayout特性支持三種附加字段:CharSet、Pack、Size。
· CharSet定義在結構中的字符串成員在結構被傳給DLL時的排列方式。可以是Unicode、Ansi或Auto。默認為Auto,在WIN NT/2000/XP中表示字符串按照Unicode字符串進行排列,在WIN 95/98/Me中則表示按照ANSI字符串進行排列。
· Pack定義了結構的封裝大小。可以是1、2、4、8、16、32、64、128或特殊值0。特殊值0表示當前操作平台默認的壓縮大小。
 .■■■ VB.NET和C#一樣, 呼叫SDK提供的功能都是使用 Platform Invocation 技巧, 即DllImport Attribute, 兩者半斤八兩, 無所謂何者較好, 只是C#可以利用 unsafe 標示使用指標, 這一點VB.NET不支援。
 .■■■ VB無所不能之一:指標

.■■■ VC++  DLL 的類型
.■■■ -  1. 建構DLL
.■ - 1.1 [ 新增專案 ]  -> 選擇 [ 類別庫 ]
.■ - 1.2 撰寫程式碼

Public Class ClsSap01
    Function str01(ByVal tStr As String, ByVal tInt As Integer) As String
        Return "Begin By IT : " & vbNewLine & tStr & vbNewLine & " The Int is : " & tInt.ToString
    End Function

    Function int01(ByVal tInt01 As Integer, ByVal tint02 As Integer) As Integer
        Return (tInt01 + tint02).ToString
    End Function
End Class
.■ - 1.3 建置方案,於 Debug 目錄下取得 dll 檔
.■ -  2. 引用 DLL
.■ - 2.1 開啟新的專案,並且將 1.3 所產生的 DLL 加入參考
.■ - 2.2 Windows Form frmDLLcallTest 程式碼 :
Imports ClsItSap01

Public Class frmDLLcallTest

    Private Sub btnCall01_Click(sender As System.Object, e As System.EventArgs) Handles btnCall01.Click
        Dim mDll As New ClsItSap01.ClsSap01

        txtMsg.Text = mDll.str01("dll call test ", 300)
        txtMsg.Text &= vbNewLine & mDll.int01(40, 532)
    End Sub
End Class
.■ -
.■ -Structure的東西是ByVal的,而Class是ByRef的!
用C的語言來說,就是Structure是copymem的,Class是改指針的。

class 可以當作 C 裡面的指針用。

.■■■ - [VB.NET] 動態使用DLL
.■■■ - 如果是 Win32API 的 DLL , 要用 DllImport  , Win32API 就是 Windows 系統內建的一些功能 ( ? )
.■■■ - 我用VC++寫了一個DLL檔要讓VB呼叫, 在VC++的compile都過了,但是在VB.net要加入參考的地方一直出現"這不是有效的組間或COM元件。.........請確定這是一個可存取的檔案。"
這個錯誤訊息,不知道哪理出問題了?
要把DLL包成COM,或是將原來的程式以C++.NET改寫編譯,應該就可以在[加入參考]-[專案]裡可以參考到
.■■■ - 使用vs2005呼叫 delphi所寫的 dll檔會出現如下錯誤, "無法加入c:\windows\xxx.dll的參考,請確定這是一個可存取的檔案,而且是一個有效的組件或COM元件", 有其他辦法可以讓.net使用 delphi的dll檔嗎?

.■■■ - VB.NET特性----Dllimport特性
.■■■ - VB.NET編程中調用WindowsAPI
.■■■ - 呼叫外部DLL或API的宣告
.■■■ -
.■■■ - (VC++ 6 ) This series of articles discusses four common situations when working with DLLs:
Part 1 Calling a DLL C++ function from a VC++ application
Calling a DLL C++ class from a VC++ application
Part 2 Calling a DLL C++ function from a VB application
Part 3 Calling a DLL C++ class from a VB application
Part 4 Loading a C++ DLL dynamically from a VC++ application

.■■■ - 逐步解說:呼叫 Windows API (Visual Basic)
.■■■ - DllImport的用法...等綜合問題集
.■■■ -
.■■■ -
.■■■ -
.■■■ -
.■■■ -
.■■■ -
.■■■ -
.■■■ -
.■■■ -
.■■■ -
Table 1
MS C/C++
MS C# ( VB.Net )
HANDLE, LPDWORD, LPVOID, void*IntPtr
LPCTSTR, LPCTSTR, LPSTR, char*,const char*, Wchar_t*, LPWSTRString [in], StringBuilder [in, out]
DWORD, unsigned long, UlongUInt32, [MarshalAs(UnmanagedType.U4)]
boolbool
LP[In] ref
SIZE_Tuint
LPDWORDout uint
LPTSTR[Out] StringBuilder
PULARGE_INTEGERout ulong
WORDuInt16
Byte, unsigned charbyte
ShortInt16
Long, intInt32
floatsingle
doubledouble
NULL pointerIntPtr.Zero
UintUInt32

.■■■ -
Windows Data Type .NET Data Type C# Data Type VB.Net Data Type
BOOL, BOOLEAN Boolean or Int32 bool or int Boolean or Integer
BSTR String string String
BYTE Byte byte Byte
CHAR Char char Char
DOUBLE Double double Double
DWORD Int32 or UInt32 int Integer
FLOAT Single float Single
HANDLE (and all other handle types, such as HFONT and HMENU) IntPtr, UintPtr or HandleRef IntPtr, UintPtr or HandleRef IntPtr, UintPtr or HandleRef
HRESULT Int32 or UInt32 int or uint Integer or UInteger
INT Int32 int Integer
LANGID Int16 or UInt16 short Short
LCID Int32 or UInt32 int or uint Integer or UInteger
LONG Int64 long Long
LPARAM IntPtr, UintPtr or Object IntPtr, UintPtr or Object IntPtr, UintPtr or Object
LPCSTR String string String
LPCTSTR String string String
LPCWSTR String string String
LPSTR String or StringBuilder* string or StringBuilder String or StringBuilder
LPTSTR String or StringBuilder string or StringBuilder String or StringBuilder
LPWSTR String or StringBuilder string or StringBuilder String or StringBuilder
LPVOID IntPtr, UintPtr or Object IntPtr, UIntPtr or object IntPtr, UIntPtr or Object
LRESULT IntPtr IntPtr IntPtr
SAFEARRAY .NET array type .NET array type .NET array type
SHORT Int16 short Short
TCHAR Char char Char
UCHAR Byte byte Byte
UINT UInt32 uint UInteger
ULONG ULong ulong ULong
VARIANT Object object Object
VARIANT_BOOL Boolean bool Boolean
WCHAR Char char Char
WORD Int16 or UInt16 short Short
WPARAM IntPtr, UintPtr or Object IntPtr, UintPtr or Object IntPtr, UintPtr or Object

.■■■ -
-
-

2013/01/11

VB.Net 存取 SQL Stored Procedure

● -- ● VB.Net 存取 SQL Stored Procedure (預儲程序 , 預存程序)

.■■■ - 用CREATE PROC的方式來建立一個stored procedure。用EXEC <參數>來執行它。
.■■■ - SQL預存程序 Stored Procedure 教學 ( edu.tw Link )
.■■■ - Stored Procedure教學

.■■■ - VB.NET調用SQL Server存儲過程 (cn)
.■■■ - 如何可以在 VB 引用 SQL 中的 Stored Procedures
.■■■ - 在storedprocedure中使用類似程式的for迴圈用法
.■■■ - SQL Stored Procedure : Null 的小學問
.■■■ - vb.net 怎麼獲得sql的存儲過程的返回值- CSDN論壇
.■■■ - 如何在VB.net中調用SQL Server 2008的存儲過程
.■■■ -
.■■■ -
.■■■ - 在 stored procedure 中使用類似程式的for迴圈用法
.■■■ - VB6如何用Sql Server 的 Stored Procedure

.■■■ -
.■■■ -
.■■■ -
.■■■ -
.■■■ -
.■■■ -


-
-

2013/01/09

PhotoShop Paint.Net Photoscape 教學 memo

● -- ● PhotoShop ;; Paint.Net ;; Photoscape 教學 memo
.■■■ - PhotoShop Teach :
.■ - 兔兔Photoshop 教學 ;;

.■ - 奧米加 - 提倡全民修片運動,人人都是修片大師

.■ - 【飛肯設計】教學網
.■ - Photoshop 教學.CG數位學習網
.■ -
.■ -
.■ -
.■ -
.■ -

.■■■ -
.■■■ -
.■■■ -
.■■■ -
.■■■ -
.■■■ -
.■■■ -

-
-

2013/01/02

iPhone5 memo

● -- ● iPhone5 memo
在您的 iPhone 和 iPad 上同步 Gmail、日曆和聯絡人 Google-Support
.■■■ - CardDAV:同步 Google 通訊錄到 iPhone 的新方法 :
  •     打開「設定 - 郵件、聯絡資訊、行事曆」
  •     選擇「新增帳號 - 其他」
  •     在聯絡資訊一欄選擇「新增CardDAV 帳號」
  •     填寫服務器(Google.com)、用戶名(Google 帳戶郵箱地址)和密碼(Google 帳戶密碼)
  •     點下一步
之後就會開始同步,約1-2分鐘完畢,打開iPhone 通訊錄,會發現Google 通訊錄中的聯絡人列表已同步到手機中了。

.■■■ - [iphone]利用CalDav同步google行事曆 : 設定--> 電子郵件/聯絡資訊/行事曆--> 新增帳號--> 選擇其他-- 新增CalDAV帳號 --
  • 伺服器 : www.google.com (若為其它廠商行事曆,請自行查詢)
  • 使用者名稱 : 請輸入完整的gmail帳號
  • 密碼 : gmail密碼
  • 描述 : 給自己識別用的,
.■■■ - 放棄 Exchange 設定法,Google Contacts 就用 CardDav,Google Calendar 就用 CalDav,然後 GMail 另外下載 GMail 軟體

.■■■ - Google 開始支援 CardDAV 標準,同步 iOS 和 Google 聯絡資訊更方便 : Google 在過去就已經支援 IMAP 和 CalDAV 開放標準,讓許多程式可以同步 Gmail 和 Google 日曆......

.■■■ - 申請Apple ID,「Email」就是您的「Apple ID」,若以後想申請別國帳號「Apple ID」,Email部份不可重覆。

.■■■ -蘋果帳號的密碼格式如下:
必須 8 位數以上,要有一個大寫英文及一個小寫英文字母,還需有一個數字,例:G123456b。

.■■■ - 中華電信 0932 xxxxxx -  800 (手機直撥) ; 0800-080-090
ADSL Tel : 0800-080-128
-
台 灣大哥大 0939 xxxxxx - ( 988 + 900上網 11/04 - 12/03帳單期 )
手機直撥 188 免費 或 02-6606 2999 基隆路二段172-1號 台灣大哥大
-
台北市大安區忠孝東路四段71號1樓 (頂好商圈) 11:00 ~ 23:00 台灣大哥大