|
cout<< pData->lgrmi1_name <<std::endl; //how can i get name here as it is printing only address like below
printf("%S\n", pData->lgrmi1_name );;
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Mogaambo wrote: cout<< pData->lgrmi1_name <<std::endl; how="" can="" i="" get="" name="" here="" as="" it="" is="" printing="" only="" address="" like="" below<="" blockquote="">
Have you tried wcout ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks to all for helping me a lot, actually i am c# programmer and i dont know all these jargons.
Thks alot
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
// adminGroup.cpp : Defines the entry point for the console application.
//
#pragma comment(lib,"Netapi32.lib")
#include <stdio.h>
#include <windows.h>
#include < LMCONS.H>
#include <Lm.h>
#include <Lmaccess.h>
#define MAX_PREFERRED_LENGTH ((DWORD) -1)
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
// NET_API_STATUS ret = 0 ;
//LPCWSTR servername = NULL;
//LPCWSTR groupname = L"Administrators";
LPBYTE buffer = NULL;
//DWORD entriesRead;
//DWORD totalEntries;
//DWORD resumeHandle =0;
//
//typedef struct _LOCALGROUP_MEMBERS_INFO_1 {
// PSID lgrmi1_sid;
// SID_NAME_USE lgrmi1_sidusage;
// LPWSTR lgrmi1_name;
//}LOCALGROUP_MEMBERS_INFO_1, *PLOCALGROUP_MEMBERS_INFO_1, *LPLOCALGROUP_MEMBERS_INFO_1;
////function call
//ret=NetLocalGroupGetMembers (NULL, groupname, 1, &buffer, MAX_PREFERRED_LENGTH, &entriesRead, &totalEntries, &resumeHandle);
//LPLOCALGROUP_MEMBERS_INFO_1 pstMembersInfo = 0;
//for( DWORD dwIdx =0; dwIdx < entriesRead; dwIdx ++ )
//{
// //std::cout<< pstMembersInfo[dwIdx].lgrmi1_name ;
//}
//int n=0;
LPLOCALGROUP_MEMBERS_INFO_1 pstMembersInfo = 0;
DWORD entriesread = 0;
DWORD totalentries = 0;
LPWSTR FromFile2=NULL;
if( 0 != NetLocalGroupGetMembers( NULL, _T("Administrators"), 1, (LPBYTE*)
&buffer,MAX_PREFERRED_LENGTH,
&entriesread, &totalentries, 0 ))
{
//AfxMessageBox( _T("NetLocalGroupGetMembers failed !"));
// return ;
}
PLOCALGROUP_MEMBERS_INFO_1 pData = (PLOCALGROUP_MEMBERS_INFO_1)buffer;
for( DWORD dwIdx =0; dwIdx < entriesread; dwIdx ++ , pData++)
{
//printf("%S\n", pstMembersInfo[dwIdx].lgrmi1_name );;
//lstrcpy(FromFile2,pstMembersInfo[dwIdx].lgrmi1_name);
//std::cout<<(std::string) pstMembersInfo[dwIdx].lgrmi1_name <<std::endl;
wcout<< pData->lgrmi1_name <<std::endl;
//printf("%S\n", pData->lgrmi1_name );;
}
NetApiBufferFree( buffer );
return 0;
}
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Essentially, I'm reading some names from a text file, and I need to allocate the array at runtime. I'm missing something regarding the allocation of each individual name. After I copy the first name into the array slot, it fills up every spot in the array with the first value. After the loop finishes I have an array with [count] copies of the initial value I read from the file.
I'm using the StreamReader class in other places in the program so that's why I'm marshaling the string to a char*. Maybe not the ideal solution, but I believe the problem is separate from that.
char **temp=NULL;
my_malloc((void**)&temp,count*sizeof(char*));
StreamReader^ din = File::OpenText(fileName);
String^ str;
while ((str = din->ReadLine()) != nullptr)
{
char* x = (char*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str).ToPointer();
my_malloc((void**)&temp[count],strlen(x)*sizeof(char)+1);
strcpy(temp[count],x);
System::Runtime::InteropServices::Marshal::FreeHGlobal((IntPtr)x);
count++;
}
The my_malloc function is just a wrapper around free() and malloc().
Thanks for the help.
|
|
|
|
|
FYI
int my_malloc(void **param_adr, int param_size)
{
my_free(param_adr);
if ((*param_adr = malloc(param_size)) == NULL)
{
return -1;
}
memset(*param_adr,0,param_size);
return 0;
}
void my_free(void **param_adr)
{
if (*param_adr != NULL)
{
free(*param_adr);
*param_adr = NULL;
}
return;
}
|
|
|
|
|
You're mixing managed and unmanaged code in a very strange way.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I know. This was the quick and dirty solution, but i'm open to alternatives.
|
|
|
|
|
How about using an <a href="http://msdn.microsoft.com/en-us/library/ts4c4dw6(VS.80).aspx">array</a><<a href="http://msdn.microsoft.com/en-us/library/system.string(VS.80).aspx">String</a>^>^ (i.e. a C++/CLI array of C++/CLI strings) instead of standard C types?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Well, I need the array in that format because I'm working with another proprietary API that works only with standard C types.
|
|
|
|
|
jlgeris wrote: temp[count]
When you allocated temp, you allocated temp[0] to temp[count-1] - temp[count] is undefined. Either use a different index variable or reset count to 0
jlgeris wrote: strlen(x)*sizeof(char)+1
As sizeof(char)==1, it makes no difference, but you really wanted (strlen(x)+1)*sizeof(char)
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello,
my program takes in a large file(s) of byte code and writes it into thousands of smaller files.
The program gives an MFC42D.DLL: 0xC00000005 Access Violation when it reaches the first of two lines of code below.
<pre> siteAndChannelIDStr.Format("C:\\Network Data\\Unclassified Events\\Last Extracted\\%s\\#%d\\", siteNamesArray[listBoxIndex], OCUIDfromEALFile);
CreateDirectory(siteAndChannelIDStr, NULL);
The CString object and directory are successfully created during the previous iterations, but oddly fails this time round.
I have followed the program execution using the debugger and it falls down at "if" statement in the "Advanced direct buffer access" bit in MFC\SRC\STRCORE.cpp
<code> if (GetData()->nRefs > 1 || nMinBufLength > GetData()->nAllocLength)
I have tried setting siteAndChannelIDStr = ""; after use
And changing the Format function to one described on the microsoft website <a href="http://support.microsoft.com/kb/127038"></a>
And tried using CString Arrays for the siteNamesArray
But no luck!
Has anyone come across this type of problem before?
I have tried the program out on 3 different files, but it fails at the same line (although prog had passed this line for each previous hundreds of iterations)
It fails after subfile 4977/10893 in file1
after subfile 4901/8135 in file2
after subfile 384/13321 in file3
Any help would be greatly appreciated!
I can provide more information if necessary. I cannot put up source code as it is for my work.
Thanks,
Colm
|
|
|
|
|
The error implies GetData() is returning zero - why is that happening?
Are you running out of memory possibly?
What are the parameter values going into the function?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Just checked in the debugger and nMinBufLength is 91 for the other calls to GetBuffer() is only 55 on the call that causes the error.
So I think running out of memeory is the problem somehow...
I've tried siteAndChannelIDStr.ReleaseBuffer(); and siteAndChannelIDStr = "";
I tried shortening the lenght of the filePath and it is still failing at the same location.
What params do you require -
I cannot get anymore values - for previous iterations nRefs=-1, nDataLength=0, nAllocLength=0
Thanks again,
Colm
|
|
|
|
|
colm omahony wrote: Just checked in the debugger and nMinBufLength is 91 for the other calls to GetBuffer() is only 55 on the call that causes the error.
So I think running out of memeory is the problem somehow...
In that case, you need to be releasing memory somewhere - but what is it that's taking up all the memory?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi, I was on holidays for last while. Thanks for assistance. Will look into what is taking the memory.
|
|
|
|
|
Hello Stuart, is this a memory leak or is it likely to be something different. I am not getting a memory leak error message.
|
|
|
|
|
Either that or you're using an invalid string object in there somehow.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
OpenGL default background is black. I want the background is total transparent in Windows. Anyone has an example how to do it?
|
|
|
|
|
Never used it. A quick investigation using Google tells me that basically it is not directly supported. Some people have stated that this solution[^] works. Good luck.
|
|
|
|
|
|
This thread shows how: http://stackoverflow.com/q/4052940/176769
|
|
|
|
|
Hi all,
I have a dialog with some sliders on it. The slider are derived from CSliderCtrl.
I try to catch the LButtonDblClk message within my CSliderCtrl derived class, but the message does not arrive (Breakpoint is never hit). In the dialog the double click appears (breakpoint is hit), but only in case I click outside the slider controls. In case I click inside the slider controls nothing happens...
Any thoughts?
Regards,
jung-kreidler
|
|
|
|
|
jung-kreidler wrote: I try to catch the LButtonDblClk message within my CSliderCtrl derived class
How? Post the relevant code that is responsible.
Also I am not seeing any support for such a message in the documentation. Where have you seen information stating it does?
modified on Thursday, July 2, 2009 10:27 AM
|
|
|
|
|
The WM_LBUTTONDBLCLK can be handled with the message handler:
BEGIN_MESSAGE_MAP(MSlider, CSliderCtrl)
ON_WM_LBUTTONDBLCLK()
END_MESSAGE_MAP()
void MSlider::OnLButtonDblClk(UINT nFlags, CPoint point)
{
CSliderCtrl::OnLButtonDblClk(nFlags, point);
}
...guess you have seen such piece of code already...
|
|
|
|