﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>A1VBCode Forums / Classic Visual Basic (VB 6 or earlier) / API  / API Fundamentals ? / Latest Posts</title><generator>InstantForum.NET v4.1.1</generator><description>A1VBCode Forums</description><link>http://www.a1vbcode.com/vbforums/</link><webMaster>forums@a1vbcode.com</webMaster><lastBuildDate>Thu, 17 May 2012 02:11:39 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: API Fundamentals ?</title><link>http://www.a1vbcode.com/vbforums/Topic9910-5-1.aspx</link><description>&lt;P&gt;Your welcome&lt;/P&gt;</description><pubDate>Fri, 01 Apr 2005 16:01:28 GMT</pubDate><dc:creator>Spsp1981</dc:creator></item><item><title>RE: API Fundamentals ?</title><link>http://www.a1vbcode.com/vbforums/Topic9910-5-1.aspx</link><description>&lt;P&gt;That example cleared it up.  &lt;/P&gt;&lt;P&gt;I tried it, and the routine came up with the number I expected.  I think that also cleared up another question I had.  Apparently, the string size is not related to the size of the string, it is just a pointer to the string, so it has the same length as any other LONG.&lt;/P&gt;&lt;P&gt;Thanks for the help&lt;/P&gt;</description><pubDate>Mon, 28 Mar 2005 14:54:20 GMT</pubDate><dc:creator>DJim</dc:creator></item><item><title>RE: API Fundamentals ?</title><link>http://www.a1vbcode.com/vbforums/Topic9910-5-1.aspx</link><description>READ the text on TOP and BELOW the piece of code I wrote in my previous answer, it took me quite a long time (on a dial-up connection), so PLEASE!!!&lt;br&gt;&lt;blockquote&gt;&lt;br&gt;Public Type EXAMPLE_UDT&lt;br&gt;&lt;br&gt;  ExampleSize As Long&lt;br&gt;&lt;br&gt;  Name As String&lt;br&gt;&lt;br&gt;  Age As Integer&lt;br&gt;&lt;br&gt;  Height As Long&lt;br&gt;&lt;br&gt;End Type ‘EXAMPLE_UDT&lt;br&gt;&lt;br&gt;&lt;br&gt;Dim MyData As EXAMPLE_UDT&lt;br&gt;&lt;br&gt;With MyData&lt;br&gt;&lt;br&gt;  .Name = "Spsp_1981"&lt;br&gt;&lt;br&gt;  .Age = 22&lt;br&gt;&lt;br&gt;  .Height = 1.82&lt;br&gt;&lt;br&gt;  .ExampleSize = Len(MyData)&lt;br&gt;&lt;br&gt;End With ‘MyData&lt;br&gt;&lt;/blockquote&gt;</description><pubDate>Mon, 28 Mar 2005 12:35:05 GMT</pubDate><dc:creator>Spsp1981</dc:creator></item><item><title>RE: API Fundamentals ?</title><link>http://www.a1vbcode.com/vbforums/Topic9910-5-1.aspx</link><description>&lt;P&gt;Here's my problem. Your example is:&lt;/P&gt;&lt;P&gt;Public Type EXAMPLE_UDT&lt;BR&gt;  Name   As String&lt;BR&gt;  Age    As Integer&lt;BR&gt;  Height As Long&lt;BR&gt;End Type 'EXAMPLE_UDT&lt;/P&gt;&lt;P&gt;But my DLL requires a change to your example&lt;/P&gt;&lt;FONT face="Times New Roman" size=3&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Public Type EXAMPLE_UDT&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;  ExampleSize As Long&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;  Name As String&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;  Age As Integer&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;  Height As Long&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;End Type ‘EXAMPLE_UDT&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt; &lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;The size is part of the definition.  And I think I could figure out the ExampleSize, since I know each LONG is 8 Bytes, but I don't know the size of the Name String.  In VB you just declare Name as String, but in "C" you have to be more specific, but I can't find an example.&lt;/P&gt;&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;/FONT&gt; &lt;/P&gt;</description><pubDate>Mon, 28 Mar 2005 07:45:16 GMT</pubDate><dc:creator>DJim</dc:creator></item><item><title>RE: API Fundamentals ?</title><link>http://www.a1vbcode.com/vbforums/Topic9910-5-1.aspx</link><description>&lt;P&gt;First of all I want to state that for structure I understood UDT as commonly called between VB programmers. Tell me if I'm wrong because my mother language is not English and sometimes I misunderstand some concepts.&lt;/P&gt;&lt;P&gt;When reading about the Windows' API, I found a lot of functions that require an structure as a parameter (SHELL_NOTIFYICON for example) and a commonly used coding standard in the API requieres the structure to have a field where to store its size, so if a function has multiple versions using different structures, the function can know from the size of the structure, which version to implement. So that, when you want to store the mentioned size in the field, you use Len() which returns the size of it from the declaration. Example:&lt;/P&gt;&lt;P&gt;Public Type EXAMPLE_UDT&lt;BR&gt;  Name   As String&lt;BR&gt;  Age    As Integer&lt;BR&gt;  Height As Long&lt;BR&gt;End Type 'EXAMPLE_UDT&lt;/P&gt;&lt;P&gt;&lt;BR&gt;Each field has a predefined Data-Type which has a predefined size given by VB itself. So when you write: Len(EXAMPLE_UDT) what VB does is look the UDT's fields' data types and calculates the amount of memory it uses, and thats the information the function needs to know. Hope you understand what I hardly tried to explain. I can't remember exactly where I read about it but I believe it must have been in Bruce McKinney's HardCore Visual Basic book which comes with Visual Studio 6 MDSN&lt;BR&gt;&lt;/P&gt;</description><pubDate>Sun, 27 Mar 2005 01:59:01 GMT</pubDate><dc:creator>Spsp1981</dc:creator></item><item><title>RE: API Fundamentals ?</title><link>http://www.a1vbcode.com/vbforums/Topic9910-5-1.aspx</link><description>&lt;P&gt;I don't understand the response.&lt;/P&gt;&lt;P&gt;How can variable = Len(Structure) if structure isn't defined yet.  The SIZE of the structure is part of the definition of the structure.&lt;/P&gt;&lt;P&gt;Or am I really missing something simple here?&lt;/P&gt;</description><pubDate>Sat, 26 Mar 2005 17:05:37 GMT</pubDate><dc:creator>DJim</dc:creator></item><item><title>RE: API Fundamentals ?</title><link>http://www.a1vbcode.com/vbforums/Topic9910-5-1.aspx</link><description>Use variable = Len(Structure)</description><pubDate>Sat, 26 Mar 2005 04:12:54 GMT</pubDate><dc:creator>Spsp1981</dc:creator></item><item><title>API Fundamentals ?</title><link>http://www.a1vbcode.com/vbforums/Topic9910-5-1.aspx</link><description>&lt;P&gt;I have a bunch of questions but will list a few.&lt;/P&gt;&lt;P&gt;I referenced the Applebaum book and looked at examples, but some of the basics confound me.&lt;/P&gt;&lt;P&gt;I'm trying to write VB6 code to interface with a "C/C++" DLL.&lt;/P&gt;&lt;P&gt;In a VB6 module1.bas I have the following:&lt;/P&gt;&lt;P&gt;Public Type STA_PROPS&lt;BR&gt;    cbSize As Long&lt;BR&gt;    STA_DPROP_DEVADDR As String   '-  Device Address    08&lt;BR&gt;    STA_DPROP_GATEWAY As String   '-  Gateway Address   10&lt;BR&gt;    STA_DPROP_NETMASK As String   '-  Network Mask      20&lt;BR&gt;    STA_DPROP_MASK As String    'Mask of used props     38&lt;BR&gt;    &lt;BR&gt;Which are chosen from:&lt;/P&gt;&lt;P&gt;' STA_DPROP_DATETIME   '0x00000001  ///&amp;lt; Date/Time&lt;BR&gt;' STA_DPROP_DEVID      '0x00000002  ///&amp;lt; Device ID&lt;BR&gt;' STA_DPROP_ALIAS      '0x00000004  ///&amp;lt; Alias&lt;BR&gt;' STA_DPROP_LOCATION   '0x00000004  ///&amp;lt; Location ID (same as Alias - compatibility)&lt;BR&gt;' STA_DPROP_DEVADDR    '0x00000008  ///&amp;lt; Device Address&lt;BR&gt;' STA_DPROP_GATEWAY    '0x00000010  ///&amp;lt; Gateway Address&lt;BR&gt;' STA_DPROP_NETMASK    '0x00000020  ///&amp;lt; Network Mask &lt;/P&gt;&lt;P&gt;ETC&lt;/P&gt;&lt;P&gt;' STA_DPROP_MASK       '0x00FFFFFF  ///&amp;lt; Mask of Used DevProp flags&lt;/P&gt;&lt;P&gt;In my VB Form;&lt;/P&gt;&lt;P&gt;Is the DPRPOP_MASK calculated correctly ? and would it be specified as &lt;/P&gt;&lt;P&gt;Dim DPROP_MASK As String, or as long&lt;/P&gt;&lt;P&gt;DPROP_MASK = &amp;amp;H38,  or "0x00000038" or what&lt;/P&gt;&lt;P&gt;How would I DIM the string mystring = "abcdefghij"&lt;/P&gt;&lt;P&gt;Dim mystring As string * 10&lt;/P&gt;&lt;P&gt;or mystring * &amp;amp;HA&lt;/P&gt;&lt;P&gt;or mystring&lt;/P&gt;&lt;P&gt;How do I calculate the cbsize (Size of the structure)&lt;/P&gt;&lt;P&gt;what if the structure had 2 LONG variables, and the above string, how would I calculate the size?&lt;/P&gt;&lt;P&gt;Thanks for any help?&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Fri, 25 Mar 2005 22:36:01 GMT</pubDate><dc:creator>DJim</dc:creator></item></channel></rss>
