Simulating Pointers In .Net?

Jun 9, 2010

have a 2d array of structures that holds about 5 or 6 details on each cell. The array size will not be known at compile time so I am using ReDim to resize it. I also have a list (think I have it as an arraylist actually but shouldn't matter really) that I would like to hold a pointer to one of the 2d array elements (as well as some other info). The list is a much smaller subset of the 2d array. The reason I am doing this is that the list needs to be sorted based on some data in the 2d array that will be changing. I don't want to have to search through the list each time to update the values as these lists and arrays can potentially be very large.

Maybe there is a better way to handle this but even if there is I would like to know how to simulate pointers in VB.Net. I know there are IntPtr's and references that I could probably use but I have no idea how to do it with dynamic arrays of structures. I'm familair with pointers from C++ but this is the first time I have tried to use (or simulate since there seems to be no real support for them) in VB.Net.

Not sure how clear that was so here are some snippets of the data types involved and some initialization.

Code:
'structures that are in the 2d array
Structure SearchNode

[code]....

View 6 Replies


ADVERTISEMENT

Manage Pointers In .Net?

Dec 15, 2010

Id'like to pass some variables (string and integers) to a class, and when I call a method of that class, it has to change the original variable.I know it was not impossible in C#, but I'm using VB2010, I made a C# project into my solution, but methods using pointers are hidden into VB. How can I make that kind of change?

An example:

Sub ChangeValues()
Dim A As Integer = 1, Str As String = "Start String"
Dim X As MyClass(A, Str)
X.ChangeInt(2)

[code]....

View 11 Replies

Multidimensional Arrays / Vectors And Pointers?

Oct 15, 2011

I'm looking for something similar to using vectors and pointers that I've used before in C++; unfortunately, it doesn't seem like there's an equivalent function in VB.net.What I have is a copy of the array behind a multi-line Rich Text Box, and I need to separate the words from each line (or element of the array) so I can analyze each one separately.In C++ I would do something like this, so I could continuously expand as needed:

[Code]...

View 6 Replies

Pasing GridView Pointers To Other Forms

Feb 3, 2012

i am new to commercial programing (and this site) I am currently studding Computer science at a university and i have hit my First roadblock.I am currently developing an application that displays a Table on one Form1 in a Read-Only format and a second Form2 which will only be displayed if after selecting a row on the Grid-View of Form1 you press an Edit button.We are doing that to avoid the User editing the DB in large. The Form2 is populated by a details view of the Table with no controls to change row on the table.What i am trying to accomplish is passing the information of which row was selected in Form1 to Form2 thus making it the current row and subsequently the only one been edited. Currently most things work but as soon as Form2 shows (Form2.show()) it will only display the first row of the database.I want to know if there is a way to "sync" the two indexes.

View 3 Replies

Pointers - Accessing Variable Addresses In .NET?

Dec 23, 2009

I have to upgrade a legacy VB6 app to VB.NET; this app uses a function call from a .dll that takes a memory address as one of it's parameters. The VB6 app does this with the VarPtr() function, but this function does not exist in .NET. How do I retrieve the memory location of a variable in .NET?

[Code]...

View 2 Replies

Pointers For A Web Sniffer/auto Responder?

Sep 11, 2011

I'm looking to make a simple web traffic sniffer that will automatically reply toauthentication requests from a predefined source, but I'm not entirely sure how tostart/what I am looking at my self here.I guess it's easier to explain if you have a short backstory;I use WebDAV, but Windows does NOT have good support for this (lacking Basic auth support, and Digest support being flawed at best), so you are forced to manuallyauthenticate with a username and password every time you open a file, when you start your computer or a word document (for example) loads resource such as images (imagine writing yoru username and password for every image in a powerpoint!).

View 2 Replies

Pointers On Doing A Multi-website Search From Within App?

May 19, 2011

have an app where the user can select to search websites I have "Hard-Coded" into the app and select categories and sub-categories to search within those websites.What i need is to figure out how to take a user defined search query (Example: The Holy Bible King James Version), then search the relevant websites (behind the scenes) then output the results something like a google or bing search, then allowing the user to download directly their search query

View 3 Replies

Pointers To Variable - Vb Doesn't Support But C# Does

Jan 17, 2010

Since vb doesnt support pointers but c# does. I am using a wrapper dll that requires a pointer to some singles to be passed within the method. I get an error that the method has some parameter types that are not supported. How can i pass a pointer to this method if vb .net doesnt support pointers.

View 4 Replies

VS 2005 Unmanaged API Using Structures/pointers And ***?

Aug 23, 2011

I am in the process of writing a tool to manage DHCP servers using the DHCP Server API. Its an unmanaged DLL so using it is a PITA at least for me it has been.Currently I am stuck trying to enumerate the IP ranges in a particular IP subnet. I am able to access an array of structures but I have only been able to access the first structure in the array of strucutres.Using this I can sucessfully access the first structure in the array.

Dim element_info_array As DHCP_SUBNET_ELEMENT_INFO_ARRAY
Dim element_data_ptr As LPDHCP_SUBNET_ELEMENT_DATA
...
element_data_ptr = DirectCast(element_info_array.Elements, LPDHCP_SUBNET_ELEMENT_DATA)

However when I use this to try and loop through them one at a time it does not work. The ptr returns 0 is null.

Dim element_info_array As DHCP_SUBNET_ELEMENT_INFO_ARRAY
Dim element_data_ptr As LPDHCP_SUBNET_ELEMENT_DATA
For i = 0 To size

[code]....

The sizeof for DHCP_SUBNET_ELEMENT_DATA could be off due incorrectly setting up the union structure for it. I was not sure how it define it so that only the first ElementType and one of the other components is avalible at any given time. It wont even read the first pointer though so that has not even come into play yet.

<StructLayout(LayoutKind.Sequential)> _
Public Structure DHCP_SUBNET_ELEMENT_DATA
Public ElementType As DHCP_SUBNET_ELEMENT_TYPE

[code]....

View 3 Replies

2008 - Use Different Types Mouse Pointers In .Net For Each Form?

Mar 28, 2009

How Should I Use Diffrent Types Mouse Pointers in .Net for Each Form? How Should I Play a mp3 sound File From "D:My Locationsound.mp3"? How Should I Create an Set up File in VB.Net 2008? How Should I Make a Form Shaped Round? How Should I Use The Mouse as Mouse Touch Event?

View 1 Replies

Passing Pointers Between C And Visual Basic 2008

Oct 27, 2009

I'm trying to call C code in the form of DLL's from Visual Basic. When I do everything passed by value I have no issues. But what I really need is to return multiple pointers to arrays of sizes I don't know at compile time (so I'd have to dynamically allocate that memory). For instance

[Code]...

Here the array sizes are hardcoded but that's for the simple fact I didn't want to copy my whole algorithm over, in my actual code I wont know the array sizes at compile time. So my questions are these:How do I make the function declaration in Visual Basic 2008? How do I free up the memory in Visual Basic that these pointers point to?

View 3 Replies

String Pointers - How To Get Name Output Parameter And Work With It

Jan 27, 2011

My application uses a third party API. This API uses a few functions that returns a value by reference as one of the function parameters. Problem is according to their documentation, the value I am trying to get out of this function is a string pointer.

So if that made no sense, heres an example of the syntax of the function as shown in their documentation:
long ExampleFunction(long ID, long PropNum, char* name, long MaxStringLength)
Input Parameters: ID, PropNum
Output Parameters: name, MaxStringLength

Thats pretty much all the info I've got. Obviously they are not using VB.Net, looks like C to me. I want to get the name output parameter and work with it, but once I get this value, I cant change anything. I know this is because its a pointer (reference type?) but I am still at a loss as to what to do.

View 1 Replies

VS 2010 - Advanced Code Which Uses Threading, Pointers

Mar 30, 2011

I had recently(2 months before ) found some code for locking the screen. Here's the link to that code submission in our CodeBank : [URL]

I wish to get a clear idea of what it actually does. As it is a bit advanced code for me.

Here's the main part of the

CODE:

View 6 Replies

VB - Pointers, Memory Allocation And Reading Writing Data?

Aug 15, 2009

I am using these API functions for my project where I am handling 3 unmanaged DLLs of two external apps, basically all it does is to carry data back and forth between these external applications. The project needs a lot of use of pointers, passing pointers and reading/writing to memory so both applications can talk to each other.

Declare Function HeapAlloc Lib "kernel32.dll" _
(ByVal hHeap As Long, ByVal dwFlags As Long, ByVal dwBytes As Long) As Long
Declare Function HeapCreate Lib "kernel32.dll" _

[code]....

set of windows API functions for allocating memory, reading and writing to allocated memory, and other required functions to generate required arguments to pass to these API calls?I am up to where I am allocating memory and getting pointer, but I don't know how to go about reading, writing, passing pointers, finding data lengths and reusing memory.

[code]....

View 6 Replies

C And C++ - Function - Extend It So That It Also Returns A Usable Array Of Pointers To Some Structures

Feb 18, 2009

Correct the problems with this function, and then extend it so that it also returns a usable array of pointers to some structures.

The extended version of this function should: Maintain the same "char *" return type which returns a pointer to a usable, for storing a C string, memory buffer.

In addition, also return a usable array of pointers to structures. This array of pointers is of variable and random length, which must be obtained using GetNumberOfSomeSeqsToGenerate(), which is called, ONLY, from within this new extended version of the function.

The type of these structures and the function that should be used to get these structures are defined as follows:

typedef struct {
char* name; /* '\0'-terminated C string */
int number;
} SomeSeq;

[CODE]...

View 2 Replies

Simulating A 'Where' Clause In A For Each Loop?

Aug 20, 2009

Is it possible to have something similar to an SQL 'WHERE' clause in a For Each loop in VB.NET?I.E.

FOR EACH event IN events
'WHERE eventdate=getdate
NEXT

View 5 Replies

Simulating Hotmail Login?

Feb 15, 2010

i had program as part of my final year project,program used smtp to send email to email to mms gateway. worked perfectly at home moved it onto set up in college and it appears they do not allow these smtp requests from campus.

basically i need to simulate a login to hotmail and to send a message without using an smtp request. Is this possible to do ?? what im looking for is minimal user input, i want to be able to hard code the username and password for the login, and also hardcode the emails recipients subject and body.

View 3 Replies

Simulating Keypresses With Sendmessage?

Nov 30, 2009

I use keybd_event and mouse_event to simulate keypresses. I want taht to still work when the user is switch (Xp supports several users as we know).

Well, it doesn't.

I've heard sendmessage is more reliable,.

I manage to simulate click easily.

SimulateClick2 = SendMessage(hwnd, BM_CLICK, 0, 0)

Now, how to do so to simulate keypresses?

View 3 Replies

Simulating Right Mouse Click?

Sep 18, 2009

I am currently attempting to simulate a mouse click within a Webbrowser control. I am able to move the cursor to where I want but i have been looking for hours for a way to make it click. An explanation as well as exemplar code is preferable as i would like to understand how it works...

View 3 Replies

VS 2008 Simulating The Effects Of Add-On?

Jul 30, 2010

There's an Add-On for FireFox called FireBug, that lets you edit the HTML of the website in Real Time. Is it possible to do that with a WebBrowser is VB .NET? I basically want to edit the HTML of a website I'm browsing in the WebBrowser Control.

View 2 Replies

Error When Simulating Virtuial Keypress?

Oct 11, 2011

Option Explicit On
Public Class Form1
Dim VirtuialSetting As String = "off"

[code]....

According to the examples I have seen, 4 exactly, this code should work, however, instead of simulating a virtual shift key pressing button1 results in an error. I would post the error, but I would have to restart my computer as it causes problems including a permanent caps lock and a problem with the mouse that opens another instance of the program when clicking on it's icon in the task bar, instead of maximizing it. These are the only side effec

View 2 Replies

Simulating A Auto Mouse Click?

Jun 19, 2012

ulating a auto mouse click in VB 2010 or C# Express 2010 Ive been trying for awhile now but cant find a code that works! I need a code to click a web browser on a timer say to click every 3

View 8 Replies

Simulating A Ctrl-Click On A Touchscreen?

Oct 22, 2010

I need to come up with a way for a user to select multiple non-consecutive rows of a DataGridView from a touchscreen. Using a mouse & keyboard I would just Ctrl-Click on the rows I want to select, but I dont have that option with a touchscreen.

View 9 Replies

Simulating A Real Deck Of Cards?

Sep 21, 2009

Ok here's what my code looks like as of now:

Private Sub btnDeal_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDeal.Click
Dim RandomClass As New Random()
Dim RandomNumber As Integer[code].....

View 6 Replies

Simulating Mouse Click Through Windows API

Sep 12, 2010

When I execute DoMouseClick then I get a PInvkokeStackImbalaced. I searched on google and tried some other things nothing really worked.
Public Class PerformClick
Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Const MOUSEEVENTF_LEFTDOWN As UInt32 = &H2
Const MOUSEEVENTF_LEFTUP As UInt32 = &H4
[Code] .....

View 3 Replies

Simulating Multiple Games In Background

Sep 6, 2011

I'm trying my hand at a little football simulator, along the same lines as Football Manager (except for Australian football but that's not really the point). Right now I have a code that will simulate a match in a background worker thread and then output all of the statistics and such to a text file. It's all good for simulating one game at a time but I want to do multiple games simultaneously!

This is because, like in Football Manager, I want to have multiple leagues setup so there will be lots of games that need simulating and to do them one at a time would be pretty slow. To sim the games I have a "Match Engine" module which has a metric load of variables and different procedures in it for kicking and marking the ball etc. I'm not sure how I could somehow duplicate all of these variables and procedures at runtime and run them simultaneously in different threads.

View 12 Replies

Simulating Clicks, Keyboard Input Etc In A Web View?

Apr 12, 2011

I plan on viewing the game through a webview control, which I believe is perfectly possible... unless I can't see Flash/Java content? I've been wondering how would you "simulate a click" in the web view control? And, of course, keyboard input?

View 2 Replies

Simulating Mouse Right Click After CheckBox Checked?

Mar 18, 2011

I would like to know how to code for a right mouse button click. The idea is that after a checkbox is checked I want the program to stimulate a right click.

View 9 Replies

Simulating Multiple Instances Of An Embedded Processor

Jan 10, 2012

I'm working on a project which will entail multiple devices, each with an embedded (ARM) processor, communicating. One development approach which I have found useful in the past with projects that only entailed a single embedded processor was develop the code using Visual Studio, divided into three portions:[code]Feeding the embedded compiler/linker the code from parts 1 and 3 yields a hex file that can run on the target system. Running parts 1 and 2 together yields code which can run on the PC, with the benefit of better debugging tools and more precise control over I/O behavior (e.g. I can make the simulation code introduce certain types of random hiccups more easily than I can induce controlled hiccups on real hardware). Target code is written in C, but the simulation environment uses C++ so as to simulate I/O registers. For example, I have a PortArray data structure; the header file for the embedded compiler includes a line like unsigned char LATA @ 0xF89; and my header file for simulation includes #define LATA _IOBIT(f89,1) which in turn invokes a macro that accesses a suitable property of an I/O object, so a statement like LATA |= 4; will read the simulated latch, "or" the read value with 4, and write the new value. To make this work, the target code has to compile under C++ as well as under C, but this mostly isn't a problem. The biggest annoyance is probably with enum types (which behave as integers in C, but have to be coaxed to do so in C++).

Previously, I've used two approaches to making the simulation interactive:Compile and link a DLL with target-application and simulation code, and have VB code in the same project which interacts with it.Compile the target-application code and some simulation code to an EXE with instance of Visual Studio, and use a second instance of Visual Studio for the simulation-UI. Have the two programs communicate via TCP, so nearly all "real" I/O logic is in the simulation program. For example, the aforementioned `LATA |= 4;` would send a "read port 0xF89" command to the TCP port, get the response, process the received value, and send a "write port 0xF89" command with the result.I've found the latter approach to run a tiny bit slower than the former in some cases, but it seems much more convenient for debugging, since I can suspend execution of the unmanaged simulation code while the simulation UI remains responsive. Indeed, for simulating a single target device at a time, I think the latter approach works extremely well. My question is how I should best go about simulating a plurality of target devices (e.g. 16 of them).The difficulty I have is figuring out how to make each simulated instance get its own set of global variables. If I were to compile to an EXE and run one instance of the EXE for each simulated target device, that would work, but I don't know any practical way to maintain debugger support while doing that. Another approach would be to arrange the target code so that everything would compile as one module joined together via #include. For simulation purposes, everything could then be wrapped into a single C++ class, with global variables turning into class-instance variables. That would be a bit more object-oriented, but I really don't like the idea of forcing all the application code to live in one compiled and linked module.What would perhaps be ideal would be if the code could load multiple instances of the DLL, each with its own set of global variables. I have no idea how to do that, however, nor do I know how to make things interact with the debugger. I don't think it's really necessary that all simulated target devices actually execute code simultaneously; it would be perfectly acceptable for simulation instances to use cooperative multitasking. If there were some way of finding out what range of memory holds the global variables, it might be possible to have the 'task-switch' method swap out all of the global variables used by the previously-running instance and swap in the contents applicable to the instance being switched in. Although I'd know how to do that in an embedded context, though, I'd have no idea how to do that on the PC.

Is there any nicer way to allow simulation logic to be paused and examined in VS2010 debugger, while keeping a responsive UI for the simulator front-end, than running the simulator front end and the simulator logic in separate instances of VS2010, if the simulation logic must be written in C and the simulation front end in managed code? For example, is there a way to tell the debugger that when a breakpoint is hit, some or all other threads should be allowed to keep running while the thread that had hit the breakpoint sits paused?If the bulk of the simulation logic must be source-code compatible with an embedded system written in C (so that the same source files can be compiled and run for simulation purposes under VS2010, and then compiled by the embedded-systems compiler for use in real hardware), is there any way to have the VS2010 debugger interact with multiple simulated instances of the embedded device? Assume performance is not likely to be an issue, but the number of instances will be large enough that creating a separate project for each instance would be likely be annoying in the absence of any way to automate the process. I can think of three somewhat-workable approaches, but don't know how to make any of them work really nicely. There's also an approach which would be better if it's possible, but I don't know how to make it work.Wrap all the simulation code within a single C++ class, such that what would be global variables in the target system become class members. I'm leaning toward this approach, but it would seem to require everything to be compiled as a single module, which would annoyingly affect the design of the target system code. Is there any nice way to have code access class instance members as though they were globals, without requiring all functions using such instances to be members of the same module?Compile a separate DLL for each simulated instance (so that e.g. if I want to run up to 16 instances, I would include 16 DLL's in the project, all sharing the same source files). This could work, but every change to the project configuration would have to be repeated 16 times.Compile the simulation logic to an EXE, and run an appropriate number of instances of that EXE. This could work, but I don't know of any convenient way to do things like set a breakpoint common to all instances. Is it possible to have multiple running instances of an EXE attached to a single debugger instance?Load multiple instances of a DLL in such a way that each instance gets its own global variables, while still being accessible in the debugger. This would be nicest if it were possible, but I don't know any way to do so.If I use one VS2010 instance for the front-end, and another for the simulation logic, is there any way to arrange things so that starting code in one will automatically launch the code in the other?

View 2 Replies

VS 2008 List Box Simulating A File Browser?

May 11, 2010

I just started programming at my college and enjoying it a lot. So far only C++ and a few tutorials in VB 2008.I didn't want to stop there and wanted to keep going, but had no idea what to even try working on as I learn.After returning home from college for the summer, my family's business was in need of some program help.

We make Fence Chargers and we receive registrations of them on a regular basis. We write them down as they come in on a form. About once every month or two one of us sits down and types them into a text program similar to notepad, but was first designed to be used in MSDOS, but now used on a windows 98 machine.

(My Father started the business and practically ran it by himself since '96. We are keeping the MSDOS program, firstchoice, until we can use an easier program to keep the warranty registrations. (That and the label printers only work on that computer due to the printer port is going extinct.))

The process is simple. The user inputs the Serial Number, the person/place the owns it, when the registration was made, and optionally where it was bought. I've created a piece of the program that does that in each text field with not program and saves each registration as it's own text file. (Later I'll be adding in a feature to keep record of repairs for each fence charger. Simply, each registration file belongs to a unique charger where it saves the repair notes.)Up to this point I got done. The files are saved with no hassle. Four fields entered by the user, one text file comes out.I'm on the next step where the files are separated into folders of each fence charger model.Executable's location > Warranties > Model > Registration Files

The Second feature I'm working on is a bit of a problem for me. I may be looking at it the wrong way, or not seeing something.The Second feature is going to be a search and edit.The search feature I have not started, just yet, but the showing of files are working, but I want to have the ability to manually select a folder, refresh the list box to show what's in the folder. I got showing of one folder deep, but the next I know it won't work, but can't figure out how to allow it to extend deeper, at least one more folder by click. Then the ability to go back one.

[Code]...

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved