.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 28th, 2004, 03:13 AM
nick.tan nick.tan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 1 nick.tan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Problem on VB.net having same structure address

Dear team,



My project is using vb6 and C language. The basic idea is using Vb to pass a structure array to DLL .



Declare Sub Machine Lib "vcdll.dll" (ByRef myStruct As MyArrayStruct)

My structure is

Structure
Public setups(200) as integer
End Structure



This structure will to pass to VCdll and inside the DLL, its will create a thread (infinity loop). The structure data will be modified by time to time. These data will shown in VB6 display.



This project is successfully done. Any data change on VCdll will be seen in Vb (Since both holding a same address of structure.



But the problem occurred will I use VB.net. Since VB.net do not allow to fixed a structure array size. Then I have follow the declaration below



<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _

Public Structure MyArrayStruct
<VBFixedArray(199), MarshalAs(UnmanagedType.ByValArray, SizeConst:=200)> Public SETUPS() As Integer
End structure



Althrough, VB.net and VCdll able to communicate, but the data update on VB.net will not work accordingly.


For example

- VCdll (thread) => while (true){ struc.setup(0) ++; }, Vb.net can be only allow to update one time at the beginning, after end CALLBACK Machine(….)

- I suspect VB.net loss the common structure address.


-


===VCdll.dll

void __declspec(dllexport) CALLBACK Machine(struct machine *structMachine)

{

int i =1;

Pmac = structMachine;

threadID = _beginthread(PLC_PRG,1024,structMachine);

aaa = GetThreadPriority((HANDLE)threadID);



}





void PLC_PRG (void *mac)

{

i=1;

while(i)

{

Pmac ->SETUPS[0] ++;

Sleep(100);

if (Pmac ->SETUPS[0] > 100)

i=0;

}



}



The above shown Pmac ->SETUPS[0] always increment. I suppost can seen this increment in VB.net. But not the case. (Its all right in VB6).

Andbody has any idea my mistake. Please advise me. I need it urgently,



Thanks a lot

Nick
nick.tan@exis-tech.com

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Problem on VB.net having same structure address


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT